Cannot find any elements in Selenium using Internet Explorer Driver
internet-explorer, selenium-webdriver
Solution
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".
Problem
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.