Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
warpech opened this issue Mar 8, 2016 · 9 comments
Closed

Comments

@warpech
Copy link

warpech commented Mar 8, 2016

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

@warpech
Copy link
Author

warpech commented Mar 8, 2016

Also reported in webcomponents/webcomponentsjs#504, since I am not sure if this is WebComponents.js issue or Selenium issue.

@warpech
Copy link
Author

warpech commented Mar 9, 2016

Same problem with Selenium IEDriverServer 2.51.1 as well as Selenium Standalone Server 2.52

@warpech
Copy link
Author

warpech commented Mar 9, 2016

Selenium Standalone Server shows some stack trace:

c:\www>java -jar selenium-server-standalone-2.52.0.jar
15:40:49.261 INFO - Launching a standalone Selenium Server
15:40:49.308 INFO - Java: Oracle Corporation 25.65-b01
15:40:49.308 INFO - OS: Windows 10 10.0 x86
15:40:49.329 INFO - v2.52.0, with Core v2.52.0. Built from revision 4c2593c
15:40:49.377 INFO - Driver class not found: com.opera.core.systems.OperaDriver
15:40:49.377 INFO - Driver provider com.opera.core.systems.OperaDriver is not re
gistered
15:40:49.377 INFO - Driver provider org.openqa.selenium.safari.SafariDriver regi
stration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=
MAC}] does not match the current platform WIN10
15:40:49.477 INFO - RemoteWebDriver instances should connect to: http://127.0.0.
1:4444/wd/hub
15:40:49.477 INFO - Selenium Server is up and running
15:41:32.314 INFO - Executing: [new session: Capabilities [{nativeEvents=false,
enablePersistentHover=true, browserName=internet explorer, ignoreZoomSetting=tru
e, version=, platform=WINDOWS}]])
15:41:32.324 INFO - Creating a new session for Capabilities [{nativeEvents=false
, enablePersistentHover=true, browserName=internet explorer, ignoreZoomSetting=t
rue, version=, platform=WINDOWS}]
Started InternetExplorerDriver server (64-bit)
2.52.1.0
Listening on port 40366
Only local connections are allowed
15:41:34.655 INFO - Done: [new session: Capabilities [{nativeEvents=false, enabl
ePersistentHover=true, browserName=internet explorer, ignoreZoomSetting=true, ve
rsion=, platform=WINDOWS}]]
15:41:34.708 INFO - Executing: [get: http://warpech.github.io/SeleniumTest/wwwro
ot/webcomponents.html])
15:41:35.148 INFO - Done: [get: http://warpech.github.io/SeleniumTest/wwwroot/we
bcomponents.html]
15:41:35.154 INFO - Executing: [find element: By.xpath: (//h1)[1]])
15:41:45.170 INFO - Executing: [delete session: efc136cc-cc54-4f70-b4d3-5b9f6ee8
5273])
15:42:14.130 ERROR - Unexpected exception during findElement
org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with
 the remote browser. It may have died.
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'
System info: host: 'DESKTOP-ITUP0CI', ip: '10.211.55.4', os.name: 'Windows 10',
os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_65'
Driver info: driver.version: EventFiringWebDriver
Capabilities [{browserAttachTimeout=0, ie.enableFullPageScreenshot=true, enableP
ersistentHover=false, ie.forceCreateProcessApi=false, ie.forceShellWindowsApi=fa
lse, pageLoadStrategy=normal, ignoreZoomSetting=true, ie.fileUploadDialogTimeout
=3000, version=11, platform=WINDOWS, proxy={proxyType=}, nativeEvents=false, ie.
ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches
=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=ht
tp://localhost:40366/, javascriptEnabled=true, ignoreProtectedModeSettings=false
, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss}]
Session ID: 640b8d62-bb8b-43f9-9eda-30b056fddfad
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.ja
va:665)
        at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDrive
r.java:363)
        at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteW
ebDriver.java:500)
        at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
        at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDrive
r.java:355)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(Even
tFiringWebDriver.java:103)
        at com.sun.proxy.$Proxy1.findElement(Unknown Source)
        at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(E
ventFiringWebDriver.java:188)
        at org.openqa.selenium.remote.server.handler.FindElement.call(FindElemen
t.java:48)
        at org.openqa.selenium.remote.server.handler.FindElement.call(FindElemen
t.java:1)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession
.java:176)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: org.openqa.selenium.WebDriverException: java.net.SocketException: Con
nection reset
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'
System info: host: 'DESKTOP-ITUP0CI', ip: '10.211.55.4', os.name: 'Windows 10',
os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_65'
Driver info: driver.version: EventFiringWebDriver
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(Driv
erCommandExecutor.java:91)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.ja
va:644)
        ... 18 more
Caused by: java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(Unknown Source)
        at java.net.SocketInputStream.read(Unknown Source)
        at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInpu
tBufferImpl.java:139)
        at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInpu
tBufferImpl.java:155)
        at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputB
ufferImpl.java:284)
        at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(Default
HttpResponseParser.java:140)
        at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(Default
HttpResponseParser.java:57)
        at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessagePa
rser.java:261)
        at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHead
er(DefaultBHttpClientConnection.java:165)
        at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy
.java:167)
        at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRe
questExecutor.java:272)
        at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecu
tor.java:124)
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.
java:271)
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java
:184)
        at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
        at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java
:110)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttp
Client.java:184)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttp
Client.java:71)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttp
Client.java:55)
        at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(
ApacheHttpClient.java:144)
        at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHt
tpClient.java:90)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExe
cutor.java:142)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(Driv
erCommandExecutor.java:82)
        ... 19 more

@jimevans
Copy link
Member

jimevans commented 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.

@warpech
Copy link
Author

warpech commented Mar 13, 2016

Thank you for a clear response.

I assume that there is no JavaScript bridge that I could use to make Selenium compatible with the polyfill in IE11?

In my very brief look into IE Driver, I saw a mechanism of falling back to Sizzle for element finding. Isn't the WebComponents.js polyfill more or less the same thing?

@jimevans
Copy link
Member

The Sizzle fall back is vestigial, and almost entirely unused. It will be removed from the project in July. Additionally, it's not entirely an apples-to-apples comparison, since (if memory serves) the Sizzle library returns the actual DOM object, not an object which wraps the DOM object and mimics its properties.

@jpsfs
Copy link

jpsfs commented Mar 17, 2017

Hi!

I'm facing the exact same problem.
@warpech did you found a solution for this problem?

Best,

@warpech
Copy link
Author

warpech commented Mar 17, 2017

Unfortunately not.

@diemol
Copy link
Member

diemol commented Jun 29, 2020

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

@diemol diemol closed this as completed Jun 29, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants