[英]Selenium Java Internet Explorer Webdriver - Unable to find element
It seems when I run the IE browser, it is unable to find the elements via xpath with error below: 看来当我运行IE浏览器时,它无法通过xpath找到具有以下错误的元素:
WARNING: WebDriverException thrown by findElement(By.xpath: //*[@id='signOnName']) org.openqa.selenium.remote.SessionNotFoundException: session null does not exist (WARNING: The server did not provide any stacktrace information) 警告:findElement(By.xpath:// * [@ id ='signOnName'])抛出WebDriverException org.openqa.selenium.remote.SessionNotFoundException:会话null不存在(警告:服务器未提供任何堆栈跟踪信息)
I have enabled the Security settings via the code below: 我已通过以下代码启用了“安全性”设置:
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);
I found one saying that to fix it just add the remote server to the Trusted Sites (Tools > Options > Security Tab > Trusted Site)
. 我发现有人说要对其进行修复,只需将远程服务器添加到“受信任的站点” (Tools > Options > Security Tab > Trusted Site)
。 However, due to work restrictions, I don't have admin access to go to the Options in IE. 但是,由于工作限制,我没有管理员权限才能进入IE中的“选项”。 I can only do it via the automation script as per above. 我只能通过上述自动化脚本来执行此操作。
Note that this is running fine in Firefox and Chrome. 请注意,这在Firefox和Chrome中运行良好。
Try this, This might help: 试试这个,这可能会有所帮助:
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>>");
Thanks! 谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.