Cannot find any elements using Internet Explorer 11 and Selenium (any version) and IEWebDriver (any version)
Asked Answered
S

1

13

I've searched all over for an answer and I can't find any fix to my issue. I am trying to run my Selenium tests in IE11. All other browsers work fine (including Edge). A simple test as follows will cause the issue...

System.setProperty("webdriver.ie.driver.loglevel","TRACE");
System.setProperty("webdriver.ie.driver.logfile", "C:/Projects/logme.txt");
driver = new InternetExplorerDriver();
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
driver.manage().deleteAllCookies();
driver.manage().window().maximize();
driver.get("http:www.google.com");
driver.findElement(By.id("lst-ib")).click;

IE11 will launch and navigate to a URL but it cannot find any elements anywhere on any page. Again, I'm aware people have had this issue but no suggestions have fixed my problem. This is the error i get back every time:

org.openqa.selenium.NoSuchElementException: Unable to find element with id == lst-ib (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 3.23 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.2.0', revision: '8c03df6b79', time: '2017-02-23 10:51:31 +0000'System info: host: 'DESKTOP-63BRP93', ip: '10.0.110.68', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.ie.InternetExplorerDriverCapabilities [{browserAttachTimeout=0, ie.enableFullPageScreenshot=true, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.forceShellWindowsApi=false, pageLoadStrategy=normal, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:38992/, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss}]
Session ID: 0fbcebc8-6775-4a6c-b10a-47350502598f
*** Element info: {Using=id, value=lst-ib}
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

Here is what I've tried/done...

  1. Set Enabled Protected Mode to disabled for all zones
  2. Set Allow Scripting option on the advanced tab or IE options
  3. Tried every IEDriver capability known to man e.g. setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION,true);
  4. Tried IE11 32 and 64bit
  5. Attempted to find an element by, class, tagname and all the rest of the locators to no avail.
  6. Added the 2 registry keys BFCACHE for both 32 and 64bit instances of IE
  7. Cried a lot

Below is the attached logs and I've located where the code falls over. It seems to be security related but JavaScript is enabled and I don't know where else to look...

T 2017-03-06 17:27:41:529 Browser.cpp(613) Entering Browser::GetDocumentFromWindow
T 2017-03-06 17:27:41:532 Script.cpp(49) Entering Script::Initialize
T 2017-03-06 17:27:41:532 Script.cpp(70) Entering Script::AddArgument(std::wstring)
T 2017-03-06 17:27:41:532 Script.cpp(105) Entering Script::AddArgument(VARIANT)
T 2017-03-06 17:27:41:532 Script.cpp(70) Entering Script::AddArgument(std::wstring)
T 2017-03-06 17:27:41:532 Script.cpp(105) Entering Script::AddArgument(VARIANT)
T 2017-03-06 17:27:41:532 Script.cpp(169) Entering Script::Execute
T 2017-03-06 17:27:41:532 Script.cpp(477) Entering Script::CreateAnonymousFunction
W 2017-03-06 17:27:41:539 Script.cpp(494) -2147024891 [Access is denied.]: Unable to execute code, call to IHTMLWindow2::execScript failed
W 2017-03-06 17:27:41:540 Script.cpp(180) Cannot create anonymous function
W 2017-03-06 17:27:41:540 ElementFinder.cpp(98) A JavaScript error was encountered executing the findElement atom.

If anyone has seen or fixed this issue, please help me!

Thanks

Scorper answered 6/3, 2017 at 7:32 Comment(9)
I reset my IE browser settings to default when i faced this problem. Check once by resetting. It worked for me.Kreager
I tried that a number of times unfortunately. But thanks anyways!Scorper
You say you "Set Enabled Protected Mode to disabled for all zones". I assume that means you've also tried with it enabled?Stilliform
And I also assume you've made sure "Enhanced Protected Mode" is disabled?Stilliform
I notice what you have native events enabled but are not requiring window focus. It's probably unrelated, but you may encounter other problems later unless window focus is required. See: github.com/SeleniumHQ/selenium/wiki/…Stilliform
Thanks Mark, yep, i tried enabled and disabled. I kind of gave up, built a VM with Windows 7 and IE11 and the webdriver works fine. I don't know if this is Windows 10 related but I've had to move on as I couldn't find a solution.Scorper
Simon, just so you know, I've built a new Windows 10 VM (built both a Pro and Enterprise) one, set them up to be (as far as I can tell), the EXACT same setup from security updates, etc. Both of these new VM's work perfectly fine with IE11. So I really am not sure what happened to this other VM but I've kept it so I can research and hopefully identify the issue. If I find out, I will make sure to post my findings here as well as my other thread.Lyda
Cross referencing: github.com/SeleniumHQ/selenium/issues/3611Dogger
From the log it says you are using Selenium 3.2.0. What is the IEDriverServer.exe version. Make sure both are same and latestSind
R
7

Earlier, I was using IE11 with Selenium WebDriver 2.5.3 and IEDriver -2.53.0. I got the same issue. I changed the capabilities by setting some properties for IE programmatically and it worked. Here's the code snippet:

    DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
    caps.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, Configuration.getConfig("My URL"));
    caps.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
Richter answered 30/4, 2017 at 16:52 Comment(2)
Only just saw this. I logged out of stack overflow and forgot all about it. I tried that code and i'm still facing the problem. unfortunately. Looks like it has worked for you and others so back to the drawing board for me.Scorper
Did you get a solution for this?Focal

© 2022 - 2024 — McMap. All rights reserved.