There are some instances where link is present on DOM but it is hidden. We can't locate it normally and do any operation on it.
On locating it we get ElementnotVisibleException
It is generally made hidden by style="display:none;".
So to handle this situation we need to take support of JavaScriptExecutor.
Code Below :
Example 1 :
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", element);
Here element is the object of the element we are looking for.
Example 2 :
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("document.getElementById('txt'.value='ABCD'");
No comments:
Post a Comment