线程" main"中的例外情况显示org.openqa.selenium.ElementNotVisibleException :.

时间:2015-07-23 10:38:32

标签: java selenium-webdriver

我的HTML代码是

  <a class="ui-btn-right close-btn ui-link ui-btn ui-btn-a ui-icon-delete ui-btn-icon-notext ui-shadow ui-corner-all" data-iconpos="notext" data-icon="delete" data-theme="a" data-role="button" data-rel="back" href="#" role="button"></a>

Selinum代码是

driver.findElement(By.cssSelector(".ui-btn-right.close-btn.ui-link.ui-btn.ui-btn-a.ui-icon-delete.ui-btn-icon-notext.ui-shadow.ui-corner-all")).click();

例外是

Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 31 milliseconds

1 个答案:

答案 0 :(得分:0)

试试javascript执行者。

WebElement element = driver.findElement(By.cssSelector(".ui-btn-right.close-btn.ui-link.ui-btn.ui-btn-a.ui-icon-delete.ui-btn-icon-notext.ui-shadow.ui-corner-all"));

((JavaScriptExecutor)driver).executeScript("arguments[0].click();", element)

如果这不起作用,请使用以下代码制作元素(不推荐)

((JavaScriptExecutor)driver).executeScript("arguments[0].style.visibilty = 'visible'", element)