We use JavaScript to at two places as of now in web automation testing with selenium:
Interface JavaScriptExecutor in java will help to use execute javascript code in selenium
Scenarios where we use JavaScript:
1. To enter value in input field without using .sendkeys method
2. To use arguments[0].ScrollToView -- which scrolls to the element on the webpage
Interface JavaScriptExecutor in java will help to use execute javascript code in selenium
Scenarios where we use JavaScript:
1. To enter value in input field without using .sendkeys method
2. To use arguments[0].ScrollToView -- which scrolls to the element on the webpage
public void ScrollclickJS(WebElement we) {
JavascriptExecutor executor = (JavascriptExecutor) driver.getWebDriver();
executor.executeScript("arguments[0].scrollIntoView();", we);
executor.executeScript("arguments[0].click();", we);
}
No comments:
Post a Comment