Skip to content

Commit 68771d2

Browse files
added new property to skip remote tests
1 parent afaa6be commit 68771d2

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

py/conftest.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ def _initialize_driver(self):
284284
kwargs["service"] = self.service
285285
return getattr(webdriver, self.driver_class)(**kwargs)
286286

287+
@property
288+
def skip_remote_tests(self):
289+
if self._request.node.path.parts[-2] == "remote" and self.driver_class != "Remote":
290+
return True
291+
return False
292+
287293
@property
288294
def stop_driver(self):
289295
def fin():
@@ -310,7 +316,7 @@ def driver(request):
310316
pytest.skip(f"{driver_class} tests can only run on {selenium_driver.exe_platform}")
311317

312318
# skip tests in the 'remote' directory if run with a local driver
313-
if request.node.path.parts[-2] == "remote" and selenium_driver.driver_class != "Remote":
319+
if selenium_driver.skip_remote_tests:
314320
pytest.skip(f"Remote tests can't be run with driver '{selenium_driver.driver_class}'")
315321

316322
# skip tests for drivers that don't support BiDi when --bidi is enabled
@@ -458,16 +464,15 @@ def clean_options(request):
458464

459465
@pytest.fixture
460466
def firefox_options(request):
461-
_supported_drivers = SupportedDrivers()
462467
try:
463468
driver_class = request.config.option.drivers[0]
464469
except (AttributeError, TypeError):
465470
raise Exception("This test requires a --driver to be specified")
466471

467472
# skip tests in the 'remote' directory if run with a local driver
468-
_driver_class = getattr(_supported_drivers, driver_class.lower())
469-
if request.node.path.parts[-2] == "remote" and _driver_class != "Remote":
470-
pytest.skip(f"Remote tests can't be run with driver '{_driver_class}'")
473+
selenium_driver = Driver(driver_class, request)
474+
if selenium_driver.skip_remote_tests:
475+
pytest.skip(f"Remote tests can't be run with driver '{driver_class}'")
471476

472477
options = webdriver.FirefoxOptions()
473478
if request.config.option.headless:

0 commit comments

Comments
 (0)