1818from .utils import CaseInsensitiveDict
1919from . import drivers
2020
21+ import warnings
22+
2123LOGGER = logging .getLogger (__name__ )
2224
2325SUPPORTED_DRIVERS = CaseInsensitiveDict (
@@ -162,8 +164,8 @@ def driver_kwargs(
162164 firefox_options = firefox_options ,
163165 firefox_profile = firefox_profile ,
164166 edge_options = edge_options ,
165- host = pytestconfig .getoption ("host " ),
166- port = pytestconfig .getoption ("port " ),
167+ host = pytestconfig .getoption ("selenium_host " ),
168+ port = pytestconfig .getoption ("selenium_port " ),
167169 service_log_path = None ,
168170 request = request ,
169171 test = "." .join (split_class_and_test_names (request .node .nodeid )),
@@ -228,6 +230,22 @@ def selenium(driver):
228230
229231@pytest .hookimpl (trylast = True )
230232def pytest_configure (config ):
233+ if config .getoption ("host" ):
234+ warnings .warn (
235+ "--host has been deprecated and will be removed in a "
236+ "future release. Please use --selenium-host instead." ,
237+ DeprecationWarning ,
238+ )
239+ config .option .selenium_host = config .getoption ("host" )
240+
241+ if config .getoption ("port" ):
242+ warnings .warn (
243+ "--port has been deprecated and will be removed in a "
244+ "future release. Please use --selenium-port instead." ,
245+ DeprecationWarning ,
246+ )
247+ config .option .selenium_port = config .getoption ("port" )
248+
231249 capabilities = config ._variables .get ("capabilities" , {})
232250 capabilities .update ({k : v for k , v in config .getoption ("capabilities" )})
233251 config .addinivalue_line (
@@ -241,9 +259,9 @@ def pytest_configure(config):
241259 if hasattr (config , "_metadata" ):
242260 config ._metadata ["Driver" ] = config .getoption ("driver" )
243261 config ._metadata ["Capabilities" ] = capabilities
244- if all ((config .getoption ( "host" ) , config .getoption ( "port" ) )):
262+ if all ((config .option . selenium_host , config .option . selenium_port )):
245263 config ._metadata ["Server" ] = "{0}:{1}" .format (
246- config .getoption ( "host" ) , config .getoption ( "port" )
264+ config .option . selenium_host , config .option . selenium_port
247265 )
248266 config ._capabilities = capabilities
249267
@@ -395,8 +413,12 @@ def __call__(self, parser, namespace, values, option_string=None):
395413 setattr (namespace , self .dest , values )
396414 driver = getattr (drivers , values .lower ())
397415 # set the default host and port if specified in the driver module
398- namespace .host = namespace .host or getattr (driver , "HOST" , None )
399- namespace .port = namespace .port or getattr (driver , "PORT" , None )
416+ namespace .selenium_host = namespace .selenium_host or getattr (
417+ driver , "HOST" , None
418+ )
419+ namespace .selenium_port = namespace .selenium_port or getattr (
420+ driver , "PORT" , None
421+ )
400422
401423
402424def pytest_addoption (parser ):
@@ -453,14 +475,29 @@ def pytest_addoption(parser):
453475 group ._addoption (
454476 "--host" ,
455477 metavar = "str" ,
456- help = "host that the selenium server is listening on, "
478+ help = "DEPRECATED host that the selenium server is listening on, "
457479 "which will default to the cloud provider default "
458480 "or localhost." ,
459481 )
460482 group ._addoption (
461483 "--port" ,
462484 type = int ,
463485 metavar = "num" ,
486+ help = "DEPRECATED port that the selenium server is listening on, "
487+ "which will default to the cloud provider default "
488+ "or localhost." ,
489+ )
490+ group ._addoption (
491+ "--selenium-host" ,
492+ metavar = "str" ,
493+ help = "host that the selenium server is listening on, "
494+ "which will default to the cloud provider default "
495+ "or localhost." ,
496+ )
497+ group ._addoption (
498+ "--selenium-port" ,
499+ type = int ,
500+ metavar = "num" ,
464501 help = "port that the selenium server is listening on, "
465502 "which will default to the cloud provider default "
466503 "or localhost." ,
0 commit comments