【问题标题】:Webdriver not finding elements in remote IEWebdriver 在远程 IE 中找不到元素
【发布时间】:2011-08-08 13:54:26
【问题描述】:

我在使用 webdriver 时遇到了一个奇怪的问题。我有一个本地环境和一个远程环境来执行我的测试;它们在两种环境中的 Firefox 中都运行良好,但在 Internet Explorer 8 中,它们只能在本地运行。

每当我对远程服务器运行测试时,它甚至都找不到用于登录的文本框元素。我在查找元素时使用了等待,我试图将时间增加到几分钟,但没有。我可以在 IE 浏览源代码时看到该元素。我什至比较了它们生成的html,并且是相同的。

我通过 JBehave 使用 selenium(JBehave-web-selenium-3.3.4 和 selenium-ie-driver-2.0b3)

要检索我正在使用的元素:

public WebElement getElementById(String elementId){
    return getMyWaiter()
    .waitForMe(By.id(elementId), TEST_DELAY_IN_S);
}

public WebElement waitForMe(By locator, int timeout) {
        WebDriverWait wait = new WebDriverWait(driver, timeout);
        return wait.until(Waiter.presenceOfElementLocated(locator));
}


public static Function<WebDriver, WebElement> presenceOfElementLocated(
            final By locator) {
        return new Function<WebDriver, WebElement>() {
            @Override
            public WebElement apply(WebDriver driver) {
                return driver.findElement(locator);
            }
        };
    }

知道为什么会有不同的行为吗?

【问题讨论】:

    标签: internet-explorer-8 selenium webdriver jbehave


    【解决方案1】:

    我找到了问题,这是 Internet Explorer 和远程服务器的安全问题。要修复它,只需将远程服务器添加到受信任站点 (Tools &gt; Options &gt; Security Tab &gt; Trusted Site)

    【讨论】:

    【解决方案2】:

    这适用于。在 IE 上转到 Internet 选项 -> 安全 -> 取消选中所有选项卡的启用保护模式。并重新运行您的项目

    【讨论】:

      猜你喜欢
      • 2016-09-07
      • 1970-01-01
      • 2016-03-20
      • 1970-01-01
      • 1970-01-01
      • 2022-11-11
      • 1970-01-01
      • 2018-09-19
      • 2017-10-24
      相关资源
      最近更新 更多