I have two pytest selenium fixtures:
- wd - webdriver fixture (widely used for all webend tests)
- wdwire - webdriverwire fixture (for request/response manipulating of webend)
Both work as they should, but I need to have a variable named like the fixture to get it to work. So it means two separate functions or renaming. I have lots of test and would like to reuse the same code, just changing the fixture and function parameter.
@pytest.mark.usefixtures("wdwire")
def test01_userportal_security(self, wdwire):
""" using wdwire webdriver """
url = tools.urls.urls['user-portal']['url']
wdwire.get(url)
:
@pytest.mark.usefixtures("wd")
def test01_userportal_security(self, wd):
""" using standard webdriver """
url = tools.urls.urls['user-portal']['url']
wd.get(url)
:
Any way to add a variable to remap wd/wdwire so they can use the same function with a parameter change?
Tried:
@pytest.mark.usefixtures("wdwire")
def test01_userportal_security(self, wd=wdwire):
""" using wdwire webdriver """
url = tools.urls.urls['user-portal']['url']
wd.get(url)
:
gives: NameError: name 'wd' is not defined
@pytest.mark.usefixtures("wdwire")
def test01_userportal_security(self, wd="wdwire"):
""" using wdwire webdriver """
url = tools.urls.urls['user-portal']['url']
wd.get(url)
:
gives: AttributeError: 'str' object has no attribute 'get'