Reputation: 251
I cannot get Selenium to identify any elements with Internet Explorer Driver regardless of the page used or the selection type.
String iedriver = "C:\\selenium-server\\IEDriverServer.exe";
System.setProperty("webdriver.ie.driver", iedriver);
WebDriver driver = new InternetExplorerDriver();
driver.get("http://www.google.com");
WebElement element = driver.findElement(By.xpath("//body"));
Selecting by xpath gives org.openqa.selenium.InvalidSelectorException: The xpath expression '//body' cannot be evaluated or does notresult in a WebElement. Other selection types also fail:
WebElement element = driver.findElement(By.cssSelector("body"));
or
WebElement element = driver.findElement(By.tagName("body"));
or
WebElement element = driver.findElement(By.name("q"));
By CSS Selector, Name, or Tag Name always results in org.openqa.selenium.NoSuchElementException
All selections work perfectly fine with Firefox Driver, Chrome Driver, and even Html Unit Driver.
The browser correctly starts and the page loads as expected. driver.getCurrentUrl(); and driver.getPageSource(); return the expected values.
I tried introducing explicit and implicit waits before selecting an element but to no effect, using
Thread.sleep(10000);
or
WebDriverWait(driver,60).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//body")));
Also tried stepping through the code to manually wait for elements to be displayed.
Other things I tried included 1) setting the security settings to the same level in all zones 2) disabling Enhanced Protected Mode 3) setting the FEATURE_BFCACHE in the registery
I am using Selenium and IEDriverServer versions 2.41. The problem is observed running both locally and remotely. The environment is on Windows 7 64-bit using IE10 64-bit and IEDriverServer 64-bit. The same problem was observed on IE11 32-bit using IEDriverServer 32-bit. I used www.google.com here as a publicly viewable test but the problem is also observed on our internal site.
Upvotes: 14
Views: 47083
Reputation: 371
I had problems accessing multiple elements asynchronous. Putting them in an async function and writing "await" before each statement solved it for me.
Upvotes: 0
Reputation: 788
Go to IE settings> Security tab> Disable Protected mode for all zones. this activity fixed my problem.
Upvotes: 0
Reputation: 61
if you run your IDE in admin mode before running the test, it will solve the problem. Ensure the IDE is running with admin rights.
Upvotes: 6
Reputation: 232
What worked for me was the solution noted at the bottom of this page:Running local HTML pages
To fix this, please go to "Internet options" in the Tools menu (or the gear icon in newer versions). Open the Advanced tab. Scroll down to "Security" and select "Allow active content to run in files on My Computer".
A reboot was then required.
Upvotes: 9
Reputation: 161
For those experiencing the issue on IE11, here is why: Microsoft released update KB3025390 via Windows Update[1] as part of its normal "patch Tuesday" update cycle. For most users, this update is downloaded and installed without user interaction. This update breaks the IE driver when using it with IE11.
https://groups.google.com/forum/m/#!topic/selenium-users/TdY_rRNF-gw
The fix, remove the update. There is no Selenium update right now to workaround the issue.
Upvotes: 16
Reputation: 251
I was able to solve the problem by lowering the the security level in "Internet Options" in the Internet zone from "High" to "Medium-high" or "Medium".
Upvotes: 11