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
My Scenario is parameterized and I want to select the parameter value from EXCEL. I want to select sheets in the excel based on environment provided qa,uat,prod .Is there any way to dynamically select sheet value to run the parameterised tests.
Scenario: Verify Licenses
Given the <user> is logged in with <password>
Then the response should show <status>
def pytest_addoption(parser):
parser.addoption('--env',
dest='testenv',
choices=["qa","uat","prod"],
default='qa',
help='Specify environment:"qa", "uat", "prod"')
@lru_cache(maxsize = 128)
def get_env(env):
wbinput = openpyxl.load_workbook('iban/data/Licenses.xlsx')
sheetip= wbinput[env] # sheet to select based on env
maxRow=sheetip.max_row
inputData = [tuple(sheetip.cell(row=i,column=j).value for j in range(1,3)) for i in range(2,maxRow+1)]
return inputData
# this code doesnot suite me, as I have no markers for my scenario. My scenario should run for all env values but take the correponding env value for each env.
def pytest_generate_tests(metafunc):
if "env" in metafunc.fixturenames:
metafunc.parametrize("env", get_env(metafunc.config.getoption("env")))
Any help is much appreciated.
The text was updated successfully, but these errors were encountered:
My Scenario is parameterized and I want to select the parameter value from EXCEL. I want to select sheets in the excel based on environment provided qa,uat,prod .Is there any way to dynamically select sheet value to run the parameterised tests.
Referring to the issue @ pytest-dev/pytest#6374, I have added the following
In conftest.py
Any help is much appreciated.
The text was updated successfully, but these errors were encountered: