【问题标题】:Selenium RemoteWebDriver get alert text causes ClassCastExceptionSelenium RemoteWebDriver 获取警报文本导致 ClassCastException
【发布时间】:2016-07-26 17:25:20
【问题描述】:

我在本地运行 Selenium Grid。我运行了一个测试,应该检查是否显示警报。在没有 Selenium Grid 的情况下运行时,测试通过。但是当我在本地 Grid 实例上运行相同的测试时,我收到了 ClassCastException

java.lang.ClassCastException: com.google.common.collect.Maps$TransformedEntriesMap cannot be cast to java.lang.String

在这个方法调用上抛出异常

 driver.switchTo().alert();

我看到 RemoteWebDriver 执行命令DriverCommand.GET_ALERT_TEXT。 所以我的问题是如何检查在 Selenium Grid 上运行时是否存在警报?

【问题讨论】:

标签: java selenium selenium-grid selenium-firefoxdriver


【解决方案1】:

C# 示例:

new WebDriverWait(driver, DefaultTimeout)
 .Until(ExpectedConditions.AlertIsPresent())
 .Accept();

也许你可以在 Java 中找到类似的东西!?

【讨论】:

    猜你喜欢
    • 2021-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-23
    • 2012-07-22
    • 1970-01-01
    • 2016-12-11
    相关资源
    最近更新 更多