【问题标题】:Selenium Java Internet Explorer Webdriver - Unable to find elementSelenium Java Internet Explorer Webdriver - 找不到元素
【发布时间】:2018-02-07 21:19:19
【问题描述】:

运行 IE 浏览器时,似乎无法通过 xpath 找到元素,并出现以下错误:

警告:由 findElement(By.xpath: //*[@id='signOnName']) org.openqa.selenium.remote.SessionNotFoundException:会话 null 不存在(警告:服务器未提供任何堆栈跟踪 信息)

我已通过以下代码启用安全设置:

            System.setProperty("webdriver.ie.driver", prop.getProperty("IEDriverPath"));
            DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
            caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); //disable protected mode settings
            caps.setCapability("initialBrowserUrl", url);
            driver = new InternetExplorerDriver(caps);

我发现有人说要修复它只需将远程服务器添加到受信任的站点(Tools > Options > Security Tab > Trusted Site)。但是,由于工作限制,我没有管理员权限进入 IE 中的选项。我只能通过上面的自动化脚本来做到这一点。

请注意,这在 Firefox 和 Chrome 中运行良好。

【问题讨论】:

  • 什么是IE版本?
  • 详细信息:InternetExplorerDriver 服务器(32 位)3.8.0.0 browserVersion=11

标签: java selenium internet-explorer xpath selenium-webdriver


【解决方案1】:

试试这个,这可能会有所帮助:

DesiredCapabilities ieCapability = DesiredCapabilities.internetExplorer();
IEcaps .setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
System.setProperty("webdriver.ie.driver", "BrowserAgent\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver(ieCapability);
driver.get("<<URL>>");

谢谢!

【讨论】:

  • 我尝试使用上面的代码。但是,问题变得更糟,因为它甚至没有获取 URL,只是停留在地址 localhost:35064 并出现错误:这是 WebDriver 服务器的初始起始页面 ... 五月我知道您为什么建议上述行,因为它看起来类似于我的代码,除了序列?
猜你喜欢
  • 2016-04-17
  • 1970-01-01
  • 1970-01-01
  • 2022-11-11
  • 2016-09-07
  • 2017-10-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多