selenium inside windows docker container fails with ff/chrome “session deleted because of page crash”

前端 未结 1 1602
误落风尘
误落风尘 2020-12-31 03:08

DOCKER WITH SELENIUM AND ASP.NET 4.5 MVC

What am I trying to do?

Attempting to have a docker image that does following. Yes, I\'m aware there are other w

相关标签:
1条回答
  • 2020-12-31 03:51

    Just in case I will leave my solution here, maybe for someone, it will be helpful)

    So, the idea is to run the 'selenium/standalone-chrome' image in a separate container.

    First of all setup your 'docker-compose.yml' file, something like that:

    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
    

    And then in code just connect to the exist chrome instance

    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);
    

    Now you can use this chrome instance for uploading your site for testing.

    0 讨论(0)
提交回复
热议问题