Search code examples
testingselenium-grid

How to launch 50 browser instances using Selenium Grid in the same machine


I need to launch 50 browser instances (IE) in a virtual machine and execute the same Testcase 50 times parallelly on those browsers. This is a kind of Load testing and I'm not sure if it's possible with selenium Grid concept. if not I would like to know another method to perform this task.


Solution

  • You can use Docker and Docker Compose, if you are familiar with it.

    First you have to install docker (if you have linux or mac this should be easy, if not, then you can install it on windows (docker desktop). There are lots of tutorials on how to use docker.

    After your install is finished you will need to create a folder, and inside that folder you will have to create a .yml file(you can do this with notepad++). The file name should be: docker-compose.yml

    Inside that .yml file you will have to paste this code:

    version: '2'
    services:
      chrome:
        image: selenium/node-chrome:3.14.0-gallium
        volumes:
          - /dev/shm:/dev/shm
        depends_on:
          - hub
        environment:
          HUB_HOST: hub
    
      hub:
        image: selenium/hub:3.14.0-gallium
        ports:
          - "4444:4444"
    

    After you have the yaml created you will need to open a git bash terminal on the path where the .yml file is located and you will need to write the following command:

    docker-compose up -d
    

    The grid will be downloaded from docker hub and it will start soon. After 1-2 minutes you should have the grid up and running on your localhost.

    You can check it by yourself on 4444 port.

    And if you have the setup made for your local grid, then it should work, but you will not be able to see the tests running on the grid, because now they run in your docker container.

    Now if you need more nodes, just write the following command:

    docker-compose scale chrome=50
    

    And it will create 50 chrome nodes.

    However you will need to allocate a lot of resources so that container will support all that load.

    If you need more info, I am happy to help!