I am trying to run 2 tests in parallel using xdist
so before that I tried to make each test independent.
This is where I'm setting up browser.
@pytest.fixture(scope="function")
def moduleSetup(request):
driver = webdriver.Firefox()
def fin():
driver.close()
request.addfinalizer(fin)
return driver
And here are 2 tests I'm running
def test_1(moduleSetup):
print moduleSetup
moduleSetup.get('http://www.foo.com')
time.sleep(5)
def test_2(moduleSetup):
print moduleSetup
moduleSetup.get('www.bar.com')
time.sleep(5)
But when I run tests I get
<selenium.webdriver.firefox.webdriver.WebDriver (session="5aae6a2d-6940-1c47-8c21-8403f84a2acb")>
...
.<selenium.webdriver.firefox.webdriver.WebDriver (session="5aae6a2d-6940-1c47-8c21-8403f84a2acb")>
As you can see it is using same browser instance. I thought if I set scope
as function
it will create 2 browser instances?
If above works end goal is run tests in parallel like maybe using py.test -d --tx 3*popen//python=python2.7 test.py -s
? So it will launch 2 browsers simultaneously.