You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We currently use plenty of fixtures to create a test_obj. This has made the test_obj fixture very complex.
Most of the fixtures currently calls the default request fixture to get the config values:
@pytest.fixture
def browser(request):
"pytest fixture for browser"
try:
return request.config.getoption("--browser")
except Exception as e:
print("Exception when trying to run test: %s"%__file__)
print("Python says:%s"%str(e))
Solution:
Create a zero_page fixture that calls the request fixture to get all config values and returns the Zero page from PageFactory and set the driver and other values:
@pytest.fixture
def zero_page(request):
"pytest fixture for browser"
try:
page = PageFactory.get_page_object("Zero",base_url=base_url)
testname = request.node.name.split('[')[0]
page.set_calling_module(testname)
#Setup and register a driver
remote_flag = request.config.getoption("--remote_flag")
os_name = request.config.getoption("--os_name")
browser = request.config.getoption("--browser")
...
...
page.register_driver(remote_flag, os_name, os_version, browser, browser_version, remote_project_name, remote_build_name, testname)
...
...
yield page
except Exception as err:
print("Exception when trying to setup page")
print(f"Python says: {err}")
Modify the test function to use the zero_page fixture alone and use it as a driver to run the test
def test_example_form(zero_page):
...
...
The text was updated successfully, but these errors were encountered:
Problem:
We currently use plenty of fixtures to create a
test_obj
. This has made thetest_obj
fixture very complex.Most of the fixtures currently calls the default
request
fixture to get the config values:Solution:
zero_page
fixture that calls therequest
fixture to get all config values and returns theZero
page fromPageFactory
and set the driver and other values:zero_page
fixture alone and use it as a driver to run the testThe text was updated successfully, but these errors were encountered: