【问题标题】:How to select a hidden dropdown value in Selenium WebDriver using Java如何使用 Java 在 Selenium WebDriver 中选择隐藏的下拉值
【发布时间】:2015-12-29 22:58:58
【问题描述】:

我有一个在加载时隐藏的下拉菜单,单击按钮将其设置为可见,当 selenium 在浏览器中运行它时我可以看到它,但它仍然给我这个异常

org.openqa.selenium.WebDriverException: ElementNotVisibleError: Element is not currently visible and may not be manipulated'ElementNotVisibleError: Element is not currently visible and may not be manipulated' when calling method: [wdIMouse::click] Command duration or timeout: 47 milliseconds

有人可以建议我们如何解决这个问题吗?

【问题讨论】:

  • 看起来这个帖子可能会有所帮助:stackoverflow.com/questions/22110282/…
  • 在尝试亚当的建议之前,我会验证您是否给了选择足够的时间出现。您可以快速将 Thread.sleep(3000) 扔在那里,如果可以解决问题,请使用类似于stackoverflow.com/questions/32890596/… 的答案正确修复它
  • Adam 和 EGHM 这两种方法我都试过了,但没有任何效果。我尝试通过可见文本进行选择,但仍然无法正常工作。
  • 请阅读指南How do I ask a good question,尤其是关于最小、完整和可验证示例(MCVE)的部分。这将帮助您自己解决问题。如果您这样做但仍然卡住,您可以回来发布您的 MCVE、您尝试了什么以及结果如何,以便我们更好地帮助您。

标签: java selenium


【解决方案1】:

尝试使用ActionsWebDriverWait

可能是这样的

Actions builder = new Actions(driver);
WebDriverWait wait = new WebDriverWait(driver);

Action clickTheDropDown = builder.moveToElement(dd).Click(otherElement).build();

clickTheDropDown.perform();
wait.Until(Expectedcondition.VisibilityOfElement(dd);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-21
    • 1970-01-01
    • 2016-09-05
    • 1970-01-01
    相关资源
    最近更新 更多