admin管理员组文章数量:1333403
I used the same type of code to select the drop down there the code is working fine but in this case i tried to click on the button. am getting the error as Element is not currently visible and so may not be interacted with Command duration or timeout: 31 milliseconds
JavascriptExecutor executor3 = (JavascriptExecutor)driver;
executor3.executeScript("document.getElementById('iskpiFilterAction').style.display='block';");
driver.findElement(By.id("iskpiFilterAction")).click();
Thread.sleep(6000);
The Problem is the type is hidden and the html tags as follows:
<input id="iskpiFilterAction" type="hidden" value="1" name="isKpiFilterAction">
Can any one please check the code and give me solution or sample code.
I used the same type of code to select the drop down there the code is working fine but in this case i tried to click on the button. am getting the error as Element is not currently visible and so may not be interacted with Command duration or timeout: 31 milliseconds
JavascriptExecutor executor3 = (JavascriptExecutor)driver;
executor3.executeScript("document.getElementById('iskpiFilterAction').style.display='block';");
driver.findElement(By.id("iskpiFilterAction")).click();
Thread.sleep(6000);
The Problem is the type is hidden and the html tags as follows:
<input id="iskpiFilterAction" type="hidden" value="1" name="isKpiFilterAction">
Can any one please check the code and give me solution or sample code.
Share Improve this question asked Dec 5, 2013 at 2:48 testingtesting 1,79615 gold badges46 silver badges75 bronze badges 4-
what in the world is
".style.type='hidden'"
? Hidden inputs are not visible on the page, how would you click them???? – epascarello Commented Dec 5, 2013 at 2:50 - Is there any way to click the button if it is hidden please suggest me a solution – testing Commented Dec 5, 2013 at 2:53
- Please anyone give me some example for the above html tag – testing Commented Dec 5, 2013 at 3:28
- 2 It is not a button. input type hidden is NOT a BUTTON – epascarello Commented Dec 5, 2013 at 3:51
3 Answers
Reset to default 2As epascarello mentioned in the ment, #iskpiFilterAction
is not a button, it's a hidden <input>
element. Therefore, you can't click()
it here:
driver.findElement(By.id("iskpiFilterAction")).click(); // this won't work
Also, what people usually do with a element like that, which is either visible or not is use ExpectedCondition.visibilityOfElement()
like so:
WebElement foo2 = wait.until(ExpectedConditions
.visibilityOfElementLocated(By.id("iskpiFilterAction")));
Whereas, the regular way of getting a element might be:
WebElement foo2 = wait.until(ExpectedConditions
.presenceOfElementLocated(By.id("iskpiFilterAction")));
You can try to use Selenuim Actions class to simulate user interactions which will make the button visible to the user--
for example:
WebElement menu = driver.findElement(By.xpath("));
Actions build = new Actions(driver);
build.moveToElement(menu).build().perform();//Hovers the mouse over the first element which will trigger the event
WebElement m2m= driver.findElement(By.xpath(""));// finds the previouslly hidden element
m2m.click();
本文标签: javascriptSelenium Webdriver Element is not currently visibleStack Overflow
版权声明:本文标题:javascript - Selenium Webdriver: Element is not currently visible - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742238150a2438456.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论