What should I do in the case of a selenium element not visible?

146    Asked by AndrewJenkins in QA Testing , Asked on Feb 9, 2022

 I am trying to click on the save button on a popup on the same window, the popup also has a text box, to which I am able to successfully send the text, but when I attempt to click the button, an error comes as an element not visible. 


Answered by Amy Avery

Selenium element not visible exceptions can be resolved by using Explicit wait. Explicit wait in selenium will wait until the element is visible. Once it's visible you can perform the necessary operation.


Syntax for Explicit wait

WebDriverWait wait = new WebDriverWait(driver,30);
WebElement e = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("your locator value")));

In the above code selenium will wait for 30 seconds until the element is visible and once it is visible, selenium will perform the required action on it.



Your Answer

Interviews

Parent Categories