parametrize variable name when passing in function it is giving error "fixture 'xxx' not found". Could you please help me.. #11529
Replies: 1 comment
-
Marks don't work on fixtures. See the relevant section of the docs for how to do this properly. Also, please format code blocks properly in the future, your post is almost unreadable as-is. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is my conftest.py code----------
import pytest
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from browserstack.local import Local
import os
def browserstack_local():
global bs_local
bs_local = Local()
bs_local_args = { "key": "key", "forcelocal": "true" }
bs_local.start(**bs_local_args)
@pytest.mark.parametrize("deviceconfiguration",[{ "deviceName": "Samsung Galaxy S22",
"osVersion": "12.0"},{"deviceName": "iPhone 12",
"osVersion": "14"}])
@pytest.fixture(scope="class")
def testdriver(deviceconfiguration):
browserstack_local()
# Define the remote WebDriver URL and desired capabilities
BROWSERSTACK_URL = "https://username:key@hub-cloud.browserstack.com/wd/hub" # Replace with your remote server URL
desired_cap = {
'bstack:options': {
"deviceOrientation": "portrait",
"realMobile": "true",
"projectName": "Mobile Pytest Automation",
"buildName": "Build #1",
"sessionName": "Mobile Browser Automation",
"local": "true"
},
"browserName": "Chrome",
"browserVersion": "latest",
}
desired_cap.update(deviceconfiguration)
driver = webdriver.Remote(
BROWSERSTACK_URL,
desired_cap
)
And I am calling this function to another test class. And I am running that test class. Test class name is test_HomePage.py
And code is ---------
from Utilities import XLUtils
from helpers.config_helpers import get_base_url
from Pages.LoginPage import LoginPage
import os
class Test_HomePage():
#baseURL = ReadConfig.getApplicationURL()
baseURL=get_base_url()
path = os.path.relpath(
os.path.realpath(os.path.join(os.path.dirname(file), '..', 'testData', 'Automation_Data.xlsx')))
I am running pytest -s -v test_HomePage.py
and getting error --------------
fixture 'deviceconfiguration' not found**
Please let me know why getting error deviceconfiguration not found which defined in parameterization. It will really helpful.
Beta Was this translation helpful? Give feedback.
All reactions