I have 3 tests as shown in the code below to run in parallel using pytest-xdist.
from time import sleep
from selenium import webdriver
from selenium.webdriver import ChromeOptions
port = 4444
command_executor = 'http://127.0.0.1:%s/wd/hub' % port
options = ChromeOptions()
options.add_argument('--start-maximized')
options.add_argument('--no-sandbox')
options.add_argument('--autoplay-policy=no-user-gesture-required')
options.add_argument('--remote-debugging-port=9222')
def test_a():
driver = webdriver.Remote(
command_executor=command_executor,
options=options
)
driver.get('https://www.amazon.com/')
sleep(10)
def test_b():
driver = webdriver.Remote(
command_executor=command_executor,
options=options
)
driver.get('https://google.com')
sleep(10)
def test_c():
driver = webdriver.Remote(
command_executor=command_executor,
options=options
)
driver.get('https://facebook.com/')
sleep(10)
Ran the following command from command prompt.
py.test -n 3 tests/tests
I expected 3 chrome instances to be launched one for each test. But, a chrome instance is launched with 3 tabs. Only the 1st tab seems to be doing the navigation and 2nd and 3rd tabs are just empty tabs. Please see screenshot below. How do I get it to launch 3 chrome instances?
Python version: Python 3.11.4 (latest stable version) I am on the latest xdist version: pytest-xdist 3.3.1 I am running this on local selenium server launched using:
java -jar selenium-server-4.10.0.jar standalone
selenium server is also the latest version.