1414# KIND, either express or implied. See the License for the
1515# specific language governing permissions and limitations
1616# under the License.
17+ import warnings
1718
1819from selenium .webdriver .chromium .remote_connection import ChromiumRemoteConnection
1920from selenium .webdriver .common .driver_finder import DriverFinder
@@ -28,11 +29,12 @@ class ChromiumDriver(RemoteWebDriver):
2829
2930 def __init__ (
3031 self ,
31- browser_name ,
32- vendor_prefix ,
33- options : ArgOptions ,
34- service : Service ,
35- keep_alive = True ,
32+ browser_name : str = None ,
33+ vendor_prefix : str = None ,
34+ options : ArgOptions = ArgOptions (),
35+ service : Service = None ,
36+ keep_alive : bool = True ,
37+ remote_connection : ChromiumRemoteConnection = None ,
3638 ) -> None :
3739 """Creates a new WebDriver instance of the ChromiumDriver. Starts the
3840 service and then creates new WebDriver instance of ChromiumDriver.
@@ -44,25 +46,34 @@ def __init__(
4446 - service - Service object for handling the browser driver if you need to pass extra details
4547 - keep_alive - Whether to configure ChromiumRemoteConnection to use HTTP keep-alive.
4648 """
47- self .vendor_prefix = vendor_prefix
4849
49- self .service = service
50+ if browser_name :
51+ warnings .warn (
52+ "browser_name is not necessary when an Options class is used" , DeprecationWarning , stacklevel = 2
53+ )
5054
55+ self .service = service
5156 self .service .path = DriverFinder .get_path (self .service , options )
52-
5357 self .service .start ()
5458
55- try :
56- super ().__init__ (
57- command_executor = ChromiumRemoteConnection (
58- remote_server_addr = self .service .service_url ,
59- browser_name = browser_name ,
60- vendor_prefix = vendor_prefix ,
61- keep_alive = keep_alive ,
62- ignore_proxy = options ._ignore_local_proxy ,
63- ),
64- options = options ,
59+ if vendor_prefix :
60+ warnings .warn (
61+ "vendor_prefix is deprecated, use a ChromiumRemoteConnection with command_executor instead" ,
62+ DeprecationWarning ,
63+ stacklevel = 2 ,
6564 )
65+ remote_connection = ChromiumRemoteConnection (
66+ remote_server_addr = self .service .service_url ,
67+ browser_name = browser_name ,
68+ vendor_prefix = vendor_prefix ,
69+ keep_alive = keep_alive ,
70+ ignore_proxy = options ._ignore_local_proxy ,
71+ )
72+
73+ command_executor = remote_connection if remote_connection else self .service .service_url
74+
75+ try :
76+ super ().__init__ (command_executor = command_executor , options = options , keep_alive = keep_alive )
6677 except Exception :
6778 self .quit ()
6879 raise
@@ -181,8 +192,7 @@ def stop_casting(self, sink_name: str) -> dict:
181192 return self .execute ("stopCasting" , {"sinkName" : sink_name })
182193
183194 def quit (self ) -> None :
184- """Closes the browser and shuts down the ChromiumDriver executable that
185- is started when starting the ChromiumDriver."""
195+ """Ends the driver session and shuts down the ChromiumDriver executable."""
186196 try :
187197 super ().quit ()
188198 except Exception :
0 commit comments