Webdriver没有在远程IE中找到元素 [英] Webdriver not finding elements in remote IE

查看:126
本文介绍了Webdriver没有在远程IE中找到元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对webdriver有一个奇怪的问题。我有一个本地环境和一个远程环境来执行我的测试;它们在两种环境下都可以在Firefox中运行,但是使用Internet Explorer 8,它们只能在本地工作。

I'm having a strange issue with webdriver. I have a local environment and a remote environment to perform my tests; they work great in Firefox in both environment, but with Internet Explorer 8, they only work in local.

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

Whenever I run the tests against the remote server it doesn't even find the textbox elements to make the login. I'm using a wait when finding elements, and I tried to increase the time until minutes, but nothing. I can see the element in IE browsing through the source code. I even compared the html generated from both of them and is the same.

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

I'm using selenium through JBehave (JBehave-web-selenium-3.3.4 with selenium-ie-driver-2.0b3)

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

To retrieve the element I'm using:

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);
            }
        };
    }

知道不同行为的原因吗?

Any idea why the different behaviour?

推荐答案

我发现了这个问题,这是Internet Explorer和远程服务器的安全问题。要解决此问题,只需将远程服务器添加到可信站点(工具>选项>安全选项卡>可信站点

I found the issue, it's a security issue with Internet Explorer and remote servers. To fix it just add the remote server to the Trusted Sites (Tools > Options > Security Tab > Trusted Site)

这篇关于Webdriver没有在远程IE中找到元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆