Skip to content

Commit fc26b47

Browse files
added new property to skip remote tests
1 parent c4a8525 commit fc26b47

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
@@ -286,6 +286,12 @@ def _initialize_driver(self):
286286
kwargs["service"] = self.service
287287
return getattr(webdriver, self.driver_class)(**kwargs)
288288

289+
@property
290+
def skip_remote_tests(self):
291+
if self._request.node.path.parts[-2] == "remote" and self.driver_class != "Remote":
292+
return True
293+
return False
294+
289295
@property
290296
def stop_driver(self):
291297
def fin():
@@ -312,7 +318,7 @@ def driver(request):
312318
pytest.skip(f"{driver_class} tests can only run on {selenium_driver.exe_platform}")
313319

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

318324
# skip tests for drivers that don't support BiDi when --bidi is enabled
@@ -460,16 +466,15 @@ def clean_options(request):
460466

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

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

474479
options = webdriver.FirefoxOptions()
475480
if request.config.option.headless:

0 commit comments

Comments
 (0)