Parallel execution of tests using Selenoid and Python

Instruction for quickly start cluster for Selenium-tests using Docker and Selenoid. Selenoid – Selenium WebDriver protocol implementation, launching browsers in isolated Docker containers. The main application for automated testing web-application in a real browsers.

Selenoid source code and documentation: Selenoid

Used:

Selenoid Docker Python

There must be:
– Install Docker on MacOs;
– Upload Selenoid – Configuration Manager;
– Start web-UI and Hub;
– Run Python tests in parallel;

Install and configure Docker were described: HERE. In short, create a profile on Docker Hub, upload and install application: Docker Desktop, login through the terminal.

After Docker install and setup, will be upload utility Configuration Manager.

curl -s https://aerokube.com/cm/bash | bash

On Linux and Mac OS
./cm selenoid start --vnc

To override Selenoid listen port add --port flag:
./cm selenoid start --port 4445
Selenoid help / stop
./cm selenoid --help
./cm selenoid stop
$ ./cm selenoid stop
Using Docker
- Your Docker API version is 1.39
Stopping Selenoid...
Successfully stopped Selenoid
$ ./cm selenoid-ui stop
Using Docker
- Your Docker API version is 1.39
Stopping Selenoid UI...
Successfully stopped Selenoid UI
docker --version
docker image ls
docker ps -a
ipconfig getifaddr en0

ls – command list, return all Dockers tom
ps -a – show Docker containers that are currently running
ipconfig – command shows IP address on MacOs

Selenoid Web version, default: http://127.0.0.1:8080/#/

./cm selenoid-ui start

Test code example:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
 
capabilities = {
    "browserName": "chrome",
    "version": "90.0",
    "platform": "LINUX"
}
 
driver = webdriver.Remote(
    command_executor='http://localhost:4444/wd/hub',
    desired_capabilities=capabilities
)
 
try:
print 'Session ID is: %s' % driver.session_id
print 'Opening the page...'
 driver.get("http://www.python.org")
 
 assert "Python" in driver.title
 elem = driver.find_element_by_name("q")
 elem.clear()
 elem.send_keys("pycon")
 elem.send_keys(Keys.RETURN)
 assert "No results found." not in driver.page_source
print 'Taking screenshot...'
driver.get_screenshot_as_file(driver.session_id + '.png')
finally:
    driver.quit()
python test_selenide.py

Releated Post