Skip to content

Commit 08cd7f0

Browse files
committed
Adding "server" and "port" run options for pytest (for Selenium Grid)
1 parent 425fdd8 commit 08cd7f0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,8 @@ def setUp(self):
13841384
self.with_basic_test_info = (
13851385
pytest.config.option.with_basic_test_info)
13861386
self.with_page_source = pytest.config.option.with_page_source
1387+
self.servername = pytest.config.option.servername
1388+
self.port = pytest.config.option.port
13871389
self.database_env = pytest.config.option.database_env
13881390
self.log_path = pytest.config.option.log_path
13891391
self.browser = pytest.config.option.browser
@@ -1393,6 +1395,10 @@ def setUp(self):
13931395
self.highlights = pytest.config.option.highlights
13941396
self.verify_delay = pytest.config.option.verify_delay
13951397
self.timeout_multiplier = pytest.config.option.timeout_multiplier
1398+
self.use_grid = False
1399+
if self.servername != "localhost":
1400+
# Use Selenium Grid (Use --server=127.0.0.1 for localhost Grid)
1401+
self.use_grid = True
13961402
if self.with_db_reporting:
13971403
self.execution_guid = str(uuid.uuid4())
13981404
self.testcase_guid = None

seleniumbase/plugins/pytest_plugin.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ def pytest_addoption(parser):
7070
dest='with_page_source',
7171
default=False,
7272
help="Use to save page source on test failure.")
73+
parser.addoption('--server', action='store',
74+
dest='servername',
75+
default='localhost',
76+
help="""Designates the server used by the test.
77+
Default: localhost.""")
78+
parser.addoption('--port', action='store',
79+
dest='port',
80+
default='4444',
81+
help="""Designates the port used by the test.
82+
Default: 4444.""")
7383
parser.addoption('--headless', action="store_true",
7484
dest='headless',
7585
default=False,

0 commit comments

Comments
 (0)