简体   繁体   中英

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:

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)

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) . However, due to work restrictions, I don't have admin access to go to the Options in IE. I can only do it via the automation script as per above.

Note that this is running fine in Firefox and 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM