28
Creating a Selenium grid with Docker Compose and run python tests.
We are going to use docker compose for creating a Selenium grid and run some basic python tests against the grid.
As always the files can be found on GitHub .
- Download the repo,
- Open a terminal in the repo folder
- Execute "docker-compose up -d".
That will spin up the grid, when docker finish preparing your grid you should go to http://localhost:4444/grid/console just to verify that everything is ok.
And then just run a simple test against this grid.
For doing this you should create a new selenium driver pointing to the grid, if you are using python is something like this for chrome :
driver = webdriver.Remote(
command_executor="http://127.0.0.1:4444/wd/hub",
desired_capabilities={
"browserName": "chrome",
})
driver1 = webdriver.Remote(
command_executor="http://127.0.0.1:4444/wd/hub",
desired_capabilities={
"browserName": "chrome",
})
driver2 = webdriver.Remote(
command_executor="http://127.0.0.1:4444/wd/hub",
desired_capabilities={
"browserName": "chrome",
})
You can find a test example file in https://github.com/delrayo/DockerComposeSeleniumGrid/blob/main/test.py
Hope this helps you on your testing.
28