Skip to content

the pure joy of trying to get a selenium test working in an asp.net 4.5 container

Notifications You must be signed in to change notification settings

jhealy/aspnet45-docker-selenium

Repository files navigation

DOCKER WITH SELENIUM AND ASP.NET 4.5 MVC

  • Runs an ASP.NET MVC 4.5 web app
  • Has selenium driver via a c# console exe testing the code successfully

ISSUE AND RESOLUTION

  • When the Selenium test is run in Windows 10 or Windows 2016 (on-the-box or VM) it runs fine.
  • When the Selenium test is run in a Windows Server docker container, the test fails with "session deleted because of page crash".
  • When the Selenium test is run in a custom build .NET Framework oriented container in docker, the test executes successfully.

Findings

  • You cannot run a Selenium test in a stock Windows Server container at this point. Prove me wrong please.
  • You CAN run a Selenium test in a custom built Windows container.

CUSTOM WINDOWS CONTAINER FOR THE WIN

A custom Windows .NET Framework container can be built to run Selenium tests. See the instructions at how to build a Selenium / .NET Framework / Windows container to get going.

If you wish to see the Selenium tests crash (maybe you can make it work?) follow the instructions in the How to build a Selenium / .NET Framework / Windows Server container doc.

SEEMS SIMILAR TO

POSTED, BUT NO SOLUTIONS

I posted this around quite a bit. Below are the publish points. I need to go and post responses to each of the items identifying Win10 containers as a possible solution for the issue.

"They are both related to running Selenium inside a Windows docker image, and the comment I mentioned above still applies. Whereas this is something interesting, there is not really a bug caused by Selenium, if you are looking for help I pointed out resources to get it, you could also ask in StackOverflow, or join us in the IRC/Slack channel where the community can help you as well."

WINDOWS SERVER CONTAINER EFFORTS

Significant effort was spent trying to get the container to run in a variety of Windows Server containers. Some of the efforts are documented below.

  • Verbose logging enabled for selenium and trapped out logfiles. You willfind two logfiles to reference. "goodrun_log.txt" is from a Windows 10 successful test. "docker_log.txt" is the log from a failed run inside a container. See https://www.chromium.org/developers/design-documents/network-stack/netlog for info on how to enable logs for chromium.

  • About line 473 in "docker_log.txt" he docker run fails. Up to that point the log file is exactly the same as the Win10 successful text execution, as referenced in line 473 of good run, as refed in "goodrun_log.txt".

  • A variety of Chrome flags were tried. For reference, see the MvcHelloWorld45 for commented out flags. File Program.cs, line 68 and onward. An example is below for --disable-dev-shm-usage.

option.AddArgument("--disable-dev-shm-usage"); // https://github.com/elgalu/docker-selenium/issues/20#issuecomment-407101358
PS> docker run -d --name aspnet48testsrun --shm-size="1g" -p 5000:80 aspnet48testsd
  • Docker memory allocation, unsuccessful.
PS> docker run -d --name aspnet48testsrun -m inf --memory-swap inf -p 5000:80 aspnet48tests
PS> docker run -d --name aspnet48testsrun -m 2g -p 5000:80 aspnet48tests

DOCKER RUN FAIL

[1556732925.450][DEBUG]: DevTools WebSocket Event: DOM.documentUpdated 7FCEC12C5F4ADEA352BBA3DF3AF6075D {

}
[1556732925.450][DEBUG]: DevTools WebSocket Command: DOM.getDocument (id=15) 7FCEC12C5F4ADEA352BBA3DF3AF6075D {

}
[1556732925.451][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=14) 7FCEC12C5F4ADEA352BBA3DF3AF6075D {
   "result": {
      "type": "string",
      "value": "http://localhost/"
   }
}
[1556732925.531][DEBUG]: DevTools WebSocket Event: Inspector.targetCrashed 7FCEC12C5F4ADEA352BBA3DF3AF6075D {

}
[1556732925.532][INFO]: Waiting for pending navigations...
[1556732925.532][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=16) 7FCEC12C5F4ADEA352BBA3DF3AF6075D {
   "expression": "1"
}
[1556732925.532][INFO]: Done waiting for pending navigations. Status: unknown error: cannot determine loading status
from tab crashed
[1556732925.552][INFO]: [464b2b630c39434969f9b90e11b7aa37] RESPONSE Navigate ERROR unknown error: session deleted because of page crash
from unknown error: cannot determine loading status
from tab crashed
  (Session info: headless chrome=74.0.3729.108)
[1556732925.552][DEBUG]: Log type 'driver' lost 0 entries on destruction
[1556732925.552][DEBUG]: Log type 'browser' lost 0 entries on destruction

WIN10 RUN GOOD

[1556733552.098][DEBUG]: DevTools WebSocket Event: DOM.documentUpdated 193B5CE9ACD5F7CE56919120C68276A7 {

}
[1556733552.098][DEBUG]: DevTools WebSocket Command: DOM.getDocument (id=15) 193B5CE9ACD5F7CE56919120C68276A7 {

}
[1556733552.104][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=14) 193B5CE9ACD5F7CE56919120C68276A7 {
   "result": {
      "type": "string",
      "value": "http://localhost:29657/"
   }
}
[1556733552.104][DEBUG]: DevTools WebSocket Response: DOM.getDocument (id=15) 193B5CE9ACD5F7CE56919120C68276A7 {
   "root": {
      "backendNodeId": 6,
      "baseURL": "http://localhost:29657/",
      "childNodeCount": 1,
      "children": [ {
         "attributes": [  ],
         "backendNodeId": 7,
         "childNodeCount": 2,
... lots more ...

SESSION DELETED BECAUSE OF PAGE CRASH

PS C:\seleniumtests> .\SeleniumDockerTest.exe http://localhost
[chrome options:] =[--headless --no-sandbox --disable-gpu]
Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}) on port 49160
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[0501/120039.381:ERROR:network_change_notifier_win.cc(156)] WSALookupServiceBegin failed with: 0
[0501/120039.428:ERROR:audio_device_listener_win.cc(46)] RegisterEndpointNotificationCallback failed: 80070424

DevTools listening on ws://127.0.0.1:49163/devtools/browser/f33a8cd9-6411-46f5-a9ab-d69901cd53c1
[0501/120039.772:ERROR:network_change_notifier_win.cc(156)] WSALookupServiceBegin failed with: 0
[exception caught] =[OpenQA.Selenium.WebDriverException: unknown error: session deleted because of page crash
from unknown error: cannot determine loading status
from tab crashed
  (Session info: headless chrome=74.0.3729.108)
  (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.17763 x86_64)
   at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebDriver.set_Url(String value)
   at OpenQA.Selenium.Remote.RemoteNavigator.GoToUrl(String url)
   at SeleniumDockerTest.Program.DoChromeTests() in C:\dev\docker-selenium-aspnet45.git\SeleniumDockerTest\Program.cs:line 60]

WHAT HAPPENED TO THE PAGE TIMEOUT ISSUE

WebDriver Timeout error resolved -Occurs with either FireFox or Chrome tests inside docker container. FIX (requires both items below):

  • Install websocket's into the docker container. Excerpt from dockerfile:
RUN powershell -Command Add-WindowsFeature Web-WebSockets
  • Pass a very interesting set of options to the chromedriver.
option.AddArguments( "--headless","--disable-gpu", "--no-sandbox" );

THANKS

To Craig W of Microsoft PG for helping me with this...

About

the pure joy of trying to get a selenium test working in an asp.net 4.5 container

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published