简体   繁体   English

Selenium Java Internet Explorer Webdriver-无法找到元素

[英]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.

相关问题 无法在Selenium Webdriver(JAVA)中启动Internet Explorer或Chrome - Unable to start Internet Explorer or Chrome in Selenium Webdriver (JAVA) Selenium Webdriver Internet Explorer中找不到元素错误 - selenium webdriver no element found error in internet explorer Internet Explorer中的Selenium Webdriver - Selenium Webdriver in Internet explorer 使用Selenium WebDriver Java无法在IE8中找到元素 - Unable to find element in IE8 using selenium webdriver java 找不到里面的元素<figure> Selenium Webdriver Java 中的标签 - unable to find element inside <figure> tag in Selenium Webdriver Java 无法使用Internet Explorer驱动程序运行Selenium WebDriver测试 - Unable to run Selenium WebDriver tests with Internet Explorer Driver Selenium Internet Explorer 问题:org.openqa.selenium.NoSuchElementException:无法使用 xpath 找到元素 - Selenium Issue with Internet Explorer : org.openqa.selenium.NoSuchElementException : Unable to find element with xpath 无法使用Selenium Webdriver在Internet Explorer中将焦点切换到newtab /窗口 - Unable to switch focus to newtab/window in Internet Explorer using Selenium Webdriver Selenium Webdriver无法找到这一特定元素 - Selenium webdriver unable to find this one particular element Selenium Webdriver错误无法在(Bamboo)上找到元素 - Selenium webdriver error Unable to find element on (bamboo)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM