windows docker容器内的selenium出现故障,带有ff/chrome“;“由于页面崩溃而删除会话”; 具有SELENIUM和ASP.NET 4.5 MVC的DOCKER

windows docker容器内的selenium出现故障,带有ff/chrome“;“由于页面崩溃而删除会话”; 具有SELENIUM和ASP.NET 4.5 MVC的DOCKER,docker,selenium-webdriver,selenium-chromedriver,docker-for-windows,Docker,Selenium Webdriver,Selenium Chromedriver,Docker For Windows,我想做什么 正在尝试具有执行以下操作的docker映像。是的,我知道还有其他的方法来完成这场比赛,但我有一个具体的要求 运行ASP.NET MVC 4.5 web应用程序 通过c#控制台exe测试代码的selenium驱动程序 当前状态-在常规Windows 10或Windows 2016中运行测试时,测试运行正常。当测试在Windows docker容器中运行时,它会以“由于页面崩溃而删除会话”结束。注意,我关注的是chrome测试,但我们使用FireFox也得到了类似的结果 我打开了se

我想做什么

正在尝试具有执行以下操作的docker映像。是的,我知道还有其他的方法来完成这场比赛,但我有一个具体的要求

  • 运行ASP.NET MVC 4.5 web应用程序
  • 通过c#控制台exe测试代码的selenium驱动程序
当前状态-在常规Windows 10或Windows 2016中运行测试时,测试运行正常。当测试在Windows docker容器中运行时,它会以“由于页面崩溃而删除会话”结束。注意,我关注的是chrome测试,但我们使用FireFox也得到了类似的结果

我打开了selenium chrome的详细调试,并捕获了日志文件。我有两个日志文件。“goodrun_log.txt”来自Windows 10的成功测试。“docker_log.txt”是容器内失败运行的日志

关于473行,我们可以看到docker运行失败。到那时为止,日志文件与良好运行完全相同。然后砰的一声。那么,我们遗漏了什么使docker容器在那一点上失败呢

张贴至Selenium 已发布到ASP.NET docker repo,网址为

似乎类似于
  • Docker发行(linux)于2015年8月11日-/dev/shm分级-由kkochubey1
  • Docker发行(linux)2018年3月-
  • 铬驱动
  • Chromium bug(linux)-
我试过的东西
  • chrome标志(比这多得多,但是…)
option.AddArgument(“--disable dev shm usage”);//https://github.com/elgalu/docker-selenium/issues/20#issuecomment-407101358
  • 像这样重试驱动程序
  • SHM模式。命令运行,但未解决问题
docker run-d--name aspnet48testsrun--shm size=“1g”-p 5000:80 aspnet48testsd
  • 记忆
DOCKER运行失败
  • 将一组非常有趣的选项传递给chromedriver

以防万一,我会把我的解决方案留在这里,也许对某人来说,这会很有帮助)

因此,我们的想法是在一个单独的容器中运行“selenium/standalone chrome”映像

首先,设置“docker compose.yml”文件,如下所示:

version: '3.8'
services:
 chrome:
    image: <your_storage>/standalone-chrome
    restart: always
    ports: 
      - 4444:4444
    networks:
     front:
        ipv4_address: 172.16.238.5
 net-worker:
    build: <your_storage>/<your_project>
    depends_on: 
      - chrome
    networks:
     front:
        ipv4_address: 172.16.238.10 

  networks:
   front:
    driver: bridge
    ipam:
        config:
         - subnet: 172.16.238.0/24

现在你可以使用这个chrome实例上传你的网站进行测试。

对你有帮助吗?我以前一直在使用htem。如果没有这些选择,headless甚至不会开火。我今天会把它推到chromium。感谢您的对话。发布到chromedriver-于0506/19提交给chromedriver-有关于此的新闻吗?我也面临着这个问题…为什么不尝试使用“selenium/standalone chrome”映像并从当前容器连接到此容器?谢谢。客户特别想要容器中的硒,这使它“有趣”。 [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 [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 ... 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]
option.AddArguments( "--headless","--disable-gpu", "--no-sandbox" );
version: '3.8'
services:
 chrome:
    image: <your_storage>/standalone-chrome
    restart: always
    ports: 
      - 4444:4444
    networks:
     front:
        ipv4_address: 172.16.238.5
 net-worker:
    build: <your_storage>/<your_project>
    depends_on: 
      - chrome
    networks:
     front:
        ipv4_address: 172.16.238.10 

  networks:
   front:
    driver: bridge
    ipam:
        config:
         - subnet: 172.16.238.0/24
var options = new ChromeOptions();
options.AddArguments("--headless");
options.AddArgument("no-sandbox");
_chrome = new RemoteWebDriver(new Uri("http://172.16.238.5:4444/wd/hub"), options);