how to handle hidden elements in selenium webdriver
JavascriptExecutor js=(JavascriptExecutor)driver;
js.executeScript("document.getElementsByClassName(ElementLocator).click();");
how to handle hidden elements in selenium webdriver
JavascriptExecutor js=(JavascriptExecutor)driver;
js.executeScript("document.getElementsByClassName(ElementLocator).click();");
how to handle hidden elements in selenium webdriver
When the web element is hidden on the page we get
ElementNotVisibleException.
For handling hidden elements we can use:
1- Actions class: To perform the click on the hidden element we
can perform the action. First we should make that button visible
with some actions, like mouse over event, click another element,
etc. Then we perform the click, once visible.
public void hoverOverElementAndClick(WebElement element) {
Actions action = new Actions(driver);
action.moveToElement(element).perform();
element.click(); }
2- JavascriptExecuter: Selenium allows to execute JavaScript
within the context of an element, so we could write JavaScript to
perform the click event, even if it is hidden.
public void jsClick(WebElement element) {
((JavascriptExecutor) this.driver).executeScript("return
arguments[0].click();", element); }
3- Wait method Until Expected Conditions Are Met: We can
use Explicit wait conditions which are
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us