Java – how do I click on a hidden element in selenium webdriver?
•
Java
I have a grid showing some records When I click on a record and check the element, it shows that it is hidden, but it is visible in the grid
My HTML is:
<a href="http://192.168.1.6/eprint_prod_3.8/settings/othercost_add.aspx?type=edit&id=805" title="Plastic Spiral Bind" <div style="float: left; width: 99%; overflow: hidden; height: 15px; overflow: hidden"> Plastic Spiral Bind </div> </a>
The above code is hidden during inspection, but visible in the grid
Selenium Code:
driver.findElement(By.partialLinkText("Plastic Spiral Bind")).click();
Solution
First, store the element in the object. Let's say element, and then write the following code to click the hidden element:
JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("arguments[0].click();",element);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码