1515# specific language governing permissions and limitations
1616# under the License.
1717
18- import warnings
19-
20- from selenium .webdriver .chrome .options import Options as ChromeOptions
2118from selenium .webdriver .chromium .remote_connection import ChromiumRemoteConnection
22- from selenium .webdriver .common .options import BaseOptions
19+ from selenium .webdriver .common .options import ArgOptions
2320from selenium .webdriver .common .service import Service
24- from selenium .webdriver .edge .options import Options as EdgeOptions
2521from selenium .webdriver .remote .webdriver import WebDriver as RemoteWebDriver
2622
27- DEFAULT_PORT = 0
28- DEFAULT_SERVICE_LOG_PATH = None
29- DEFAULT_KEEP_ALIVE = None
30-
3123
3224class ChromiumDriver (RemoteWebDriver ):
3325 """Controls the WebDriver instance of ChromiumDriver and allows you to
@@ -37,67 +29,25 @@ def __init__(
3729 self ,
3830 browser_name ,
3931 vendor_prefix ,
40- port = DEFAULT_PORT ,
41- options : BaseOptions = None ,
42- service_args = None ,
43- desired_capabilities = None ,
44- service_log_path = DEFAULT_SERVICE_LOG_PATH ,
45- service : Service = None ,
46- keep_alive = DEFAULT_KEEP_ALIVE ,
32+ options : ArgOptions ,
33+ service : Service ,
34+ keep_alive = True ,
4735 ) -> None :
4836 """Creates a new WebDriver instance of the ChromiumDriver. Starts the
4937 service and then creates new WebDriver instance of ChromiumDriver.
5038
5139 :Args:
5240 - browser_name - Browser name used when matching capabilities.
5341 - vendor_prefix - Company prefix to apply to vendor-specific WebDriver extension commands.
54- - port - Deprecated: port you would like the service to run, if left as 0, a free port will be found.
5542 - options - this takes an instance of ChromiumOptions
56- - service_args - Deprecated: List of args to pass to the driver service
57- - desired_capabilities - Deprecated: Dictionary object with non-browser specific
58- capabilities only, such as "proxy" or "loggingPref".
59- - service_log_path - Deprecated: Where to log information from the driver.
60- - keep_alive - Deprecated: Whether to configure ChromiumRemoteConnection to use HTTP keep-alive.
43+ - service - Service object for handling the browser driver if you need to pass extra details
44+ - keep_alive - Whether to configure ChromiumRemoteConnection to use HTTP keep-alive.
6145 """
62- if desired_capabilities :
63- warnings .warn (
64- "desired_capabilities has been deprecated, please pass in a Service object" ,
65- DeprecationWarning ,
66- stacklevel = 2 ,
67- )
68- if port != DEFAULT_PORT :
69- warnings .warn ("port has been deprecated, please pass in a Service object" , DeprecationWarning , stacklevel = 2 )
70- self .port = port
71- if service_log_path != DEFAULT_SERVICE_LOG_PATH :
72- warnings .warn (
73- "service_log_path has been deprecated, please pass in a Service object" ,
74- DeprecationWarning ,
75- stacklevel = 2 ,
76- )
77- if keep_alive != DEFAULT_KEEP_ALIVE and type (self ) == __class__ :
78- warnings .warn (
79- "keep_alive has been deprecated, please pass in a Service object" , DeprecationWarning , stacklevel = 2
80- )
81- else :
82- keep_alive = True
83-
8446 self .vendor_prefix = vendor_prefix
8547
86- _ignore_proxy = None
87- if not options :
88- options = self .create_options ()
89-
90- if desired_capabilities :
91- for key , value in desired_capabilities .items ():
92- options .set_capability (key , value )
93-
94- if options ._ignore_local_proxy :
95- _ignore_proxy = options ._ignore_local_proxy
96-
97- if not service :
98- raise AttributeError ("service cannot be None" )
99-
10048 self .service = service
49+ self .options = options
50+
10151 self .service .start ()
10252
10353 try :
@@ -107,9 +57,9 @@ def __init__(
10757 browser_name = browser_name ,
10858 vendor_prefix = vendor_prefix ,
10959 keep_alive = keep_alive ,
110- ignore_proxy = _ignore_proxy ,
60+ ignore_proxy = self . options . _ignore_local_proxy ,
11161 ),
112- options = options ,
62+ options = self . options ,
11363 )
11464 except Exception :
11565 self .quit ()
@@ -240,6 +190,3 @@ def quit(self) -> None:
240190 pass
241191 finally :
242192 self .service .stop ()
243-
244- def create_options (self ) -> BaseOptions :
245- return EdgeOptions () if self .vendor_prefix == "ms" else ChromeOptions ()
0 commit comments