繁体   English   中英

使用Java的Silenium Webdriver:线程“ main” org.openqa.selenium.ElementNotVisibleException中的异常:

[英]Silenium webdriver using Java: Exception in thread “main” org.openqa.selenium.ElementNotVisibleException:

我正在使用Webdriver并尝试单击一个链接(计费),该链接进一步具有下拉菜单(“我的报价”)。 要找到帐单,然后单击“我的报价”链接,我正在使用以下代码:

String xp = "//*[@id='Primary_Navbar-Billing']/a";  // With this xpath I can search on my Firefox browser but using the same in my code gives me an error: 

WebElement menu = driver.findElement(By.xpath(xp));


    driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
    // Initiate mouse action using Actions class
    Actions builder = new Actions(driver);    

    // move the mouse to the earlier identified menu option
    builder.moveToElement(menu).build().perform();

    //identify menu option from the resulting menu display and click
    driver.findElement(By.linkText("My Quotes")).click();

我收到一个错误:

线程“主” org.openqa.selenium.ElementNotVisibleException中的异常:

您可以尝试以下三种选择:

  • 添加一个Thread.sleep(YourMilliSecondesTime); 在您单击()之前; 行动。

  • 使用Xpath代替By.linkText查找您的链接,Xpath总是更好的选择。

  • 或尝试以下方法:driver.findElement(By.xpath(“ // span [text()='YOURLINKTEXTEHERE']”)))。click()); 如果出于任何原因,您对此元素的xpath不好。

希望这会有所帮助。 :)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM