I am using below fixture in conftest.py for open and close browser : conftest.py:
@pytest.fixture(scope='session')
def browser():
print("Setting up webdriver connection...")
global driver
if driver is None:
profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True
profile.set_preference("network.proxy.type",1)
driver = webdriver.Firefox(firefox_profile=profile)
driver.maximize_window()
yield driver
driver.quit()
print("Webdriver connection closed..")
In my Test Class I have below step test_login :
def test_login(self, browser):
login_page = pagep.LoginPage(browser)
login_page.login('hptest376@gmail.com', "test12345*")
login_page.login('user', "pwd")
assert "Sum" in browser.title
And after test_login I have one more test step in my Test Class:
def test_ppt(a):
a=12
print a
Issue : I am getting error in fixture at driver.quit() and browser is not closing.
If I remove the "test_ppt(a)" step after "test_login(self, browser)" then the test runs fine.
Want to know what i need to update in my fixture "browser()" so that driver.quit() is executed.
Changed the scope of fixture to 'function' and the test is passing now.
@pytest.fixture(scope='function')
def browser():
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.