question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Selenium WebDriver for .Net does not work IE11 when WebComponents.js present

See original GitHub issue

Expected Behavior

WebDriver should be able to find an element on page.

Actual Behavior

WebDriver can’t find an element on page if WebComponents.js is loaded and the browser is IE11. This happens at least for methods By.XPath and By.CssSelector.

The below test project tries Firefox and IE11 driver. Only IE11 fails on this.

My environment is Windows 10 64-bit, using Selenium for .Net.

Versions used: NUnit 2.6.4, NUnitTestAdapter 2.0.0, Selenium.Support 2.52.0, Selenium.WebDriver 2.52.0, WebDriver.IEDriverServer.win64 2.44, WebComponents.js 0.7.21

Steps to reproduce

I have created a test project to recreate the issue: https://github.com/warpech/SeleniumTest

For example, the following test:

IWebElement element = wait.Until(driver => driver.FindElement(By.XPath("(//h1)[1]")));

Fails with error:

Test Name:  Polyfill_BodyElementExists
Test FullName:  SeleniumTests.MarcinNunit("internet explorer").Polyfill_BodyElementExists
Test Source:    C:\www\warpech\SeleniumTest\UnitTest1.cs : line 78
Test Outcome:   Failed
Test Duration:  0:00:18.645

Result StackTrace:  
at OpenQA.Selenium.Support.UI.DefaultWait`1.ThrowTimeoutException(String exceptionMessage, Exception lastException)
at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
at SeleniumTests.MarcinNunit.Polyfill_BodyElementExists() in C:\www\warpech\SeleniumTest\UnitTest1.cs:line 83
--NoSuchElementException
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByXPath(String xpath)
at OpenQA.Selenium.By.<>c__DisplayClasse.<XPath>b__c(ISearchContext context)
at OpenQA.Selenium.By.FindElement(ISearchContext context)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)
at SeleniumTests.MarcinNunit.<>c.<Polyfill_BodyElementExists>b__10_0(IWebDriver driver) in C:\www\warpech\SeleniumTest\UnitTest1.cs:line 83
at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
Result Message: 
OpenQA.Selenium.WebDriverTimeoutException : Timed out after 10 seconds
  ----> OpenQA.Selenium.NoSuchElementException : Unable to find element with xpath == (//h1)[1]

2016-03-08 18_52_20-seleniumtest - microsoft visual studio

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jimevanscommented, Mar 9, 2016

This polyfill overrides basic DOM functionality, and causes JavaScript execution to return a wrapper object instead of the actual DOM node. Since IE doesn’t have a native XPath-over-HTML engine, finding elements by XPath is done using a JavaScript XPath execution engine. Additionally, the automation atoms for finding elements are written in JavaScript, and that means finding by CSS selector similarly uses JavaScript, via querySelector(). As long as this is the case, and the polyfill is returning a wrapped JavaScript object instead of the actual DOM node, findElement() will not work for the IE driver.

0reactions
diemolcommented, Jun 29, 2020

Closing this since the thread has been stale and also thanks to the explanation given here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webcomponents.js breaks Selenium WebDriver for .Net in IE11 ...
If webcomponents.js polyfill is loaded on the page, Selenium WebDriver for ... Net does not work IE11 when WebComponents.js present SeleniumHQ/selenium#1765.
Read more >
Selenium webdriver: IE 11 element.Click() doesnt work
In Chrome and Firefox is normaly click on element. If I clik in other elements for example button it works on IE 11....
Read more >
[Code example]-Seleniun Hashmap(String, WebElement) not ...
Best coding solution for query Seleniun Hashmap(String, WebElement) not returning ... Hover and click is not working in IE11 from Selenium Webdriver ......
Read more >
Selenium Webdriver tutorial for beginners - Learn Automation
Selenium best automation tool is quite helpful. Selenium webdriver tutorial provides its users an insight and use of selenium webdriver with videos.
Read more >
Discussion of Angular struggles in 2020 - DEV Community ‍ ‍
Next a couple of things about the issues mentioned. ... In the meantime devices are getting faster, less people use IE11 and whatnot, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found