File tree Expand file tree Collapse file tree
test/selenium/webdriver/common Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919from selenium .types import SubprocessStdAlias
2020from selenium .webdriver .chromium import service
2121
22- DEFAULT_EXECUTABLE_PATH = "chromedriver"
23-
2422
2523class Service (service .ChromiumService ):
2624 """A Service class that is responsible for the starting and stopping of
@@ -35,7 +33,7 @@ class Service(service.ChromiumService):
3533
3634 def __init__ (
3735 self ,
38- executable_path : str = DEFAULT_EXECUTABLE_PATH ,
36+ executable_path = None ,
3937 port : int = 0 ,
4038 service_args : typing .Optional [typing .List [str ]] = None ,
4139 log_path : typing .Optional [str ] = None ,
Original file line number Diff line number Diff line change 1717
1818from selenium .webdriver .chromium .webdriver import ChromiumDriver
1919from selenium .webdriver .common .desired_capabilities import DesiredCapabilities
20- from selenium .webdriver .common .driver_finder import DriverFinder
2120
2221from .options import Options
2322from .service import Service
@@ -40,16 +39,13 @@ def __init__(
4039 - service - Service object for handling the browser driver if you need to pass extra details
4140 - keep_alive - Whether to configure ChromeRemoteConnection to use HTTP keep-alive.
4241 """
43- self .service = service if service else Service ()
44- self .options = options if options else Options ()
45- self .keep_alive = keep_alive
46-
47- self .service .path = DriverFinder .get_path (self .service , self .options )
42+ service = service if service else Service ()
43+ options = options if options else Options ()
4844
4945 super ().__init__ (
5046 DesiredCapabilities .CHROME ["browserName" ],
5147 "goog" ,
52- self . options ,
53- self . service ,
54- self . keep_alive ,
48+ options ,
49+ service ,
50+ keep_alive ,
5551 )
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class ChromiumService(service.Service):
3737
3838 def __init__ (
3939 self ,
40- executable_path : str ,
40+ executable_path : str = None ,
4141 port : int = 0 ,
4242 service_args : typing .Optional [typing .List [str ]] = None ,
4343 log_path : typing .Optional [str ] = None ,
Original file line number Diff line number Diff line change 1616# under the License.
1717
1818from selenium .webdriver .chromium .remote_connection import ChromiumRemoteConnection
19+ from selenium .webdriver .common .driver_finder import DriverFinder
1920from selenium .webdriver .common .options import ArgOptions
2021from selenium .webdriver .common .service import Service
2122from selenium .webdriver .remote .webdriver import WebDriver as RemoteWebDriver
@@ -46,7 +47,8 @@ def __init__(
4647 self .vendor_prefix = vendor_prefix
4748
4849 self .service = service
49- self .options = options
50+
51+ self .service .path = DriverFinder .get_path (self .service , options )
5052
5153 self .service .start ()
5254
@@ -57,9 +59,9 @@ def __init__(
5759 browser_name = browser_name ,
5860 vendor_prefix = vendor_prefix ,
5961 keep_alive = keep_alive ,
60- ignore_proxy = self . options ._ignore_local_proxy ,
62+ ignore_proxy = options ._ignore_local_proxy ,
6163 ),
62- options = self . options ,
64+ options = options ,
6365 )
6466 except Exception :
6567 self .quit ()
Original file line number Diff line number Diff line change 1515# specific language governing permissions and limitations
1616# under the License.
1717import logging
18- import shutil
1918from pathlib import Path
2019
2120from selenium .common .exceptions import NoSuchDriverException
@@ -34,13 +33,14 @@ class DriverFinder:
3433
3534 @staticmethod
3635 def get_path (service : Service , options : BaseOptions ) -> str :
37- path = shutil . which ( service .path )
36+ path = service .path
3837 try :
3938 path = SeleniumManager ().driver_location (options ) if path is None else path
4039 except Exception as err :
41- raise NoSuchDriverException (f"Unable to obtain { service .path } using Selenium Manager; { err } " )
40+ msg = f"Unable to obtain driver for { options .capabilities ['browserName' ]} using Selenium Manager; { err } "
41+ raise NoSuchDriverException (msg )
4242
4343 if path is None or not Path (path ).is_file ():
44- raise NoSuchDriverException (f"Unable to locate or obtain { service . path } " )
44+ raise NoSuchDriverException (f"Unable to locate or obtain driver for { options . capabilities [ 'browserName' ] } " )
4545
4646 return path
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ class Service(ABC):
5050
5151 def __init__ (
5252 self ,
53- executable : str ,
53+ executable : str = None ,
5454 port : int = 0 ,
5555 log_file : SubprocessStdAlias = None ,
5656 log_output : SubprocessStdAlias = None ,
Original file line number Diff line number Diff line change 2020from selenium .types import SubprocessStdAlias
2121from selenium .webdriver .chromium import service
2222
23- DEFAULT_EXECUTABLE_PATH = "msedgedriver"
24-
2523
2624class Service (service .ChromiumService ):
2725 """A Service class that is responsible for the starting and stopping of
@@ -38,7 +36,7 @@ class Service(service.ChromiumService):
3836
3937 def __init__ (
4038 self ,
41- executable_path : str = DEFAULT_EXECUTABLE_PATH ,
39+ executable_path : str = None ,
4240 port : int = 0 ,
4341 verbose : bool = False ,
4442 log_path : typing .Optional [str ] = None ,
Original file line number Diff line number Diff line change 1717
1818from selenium .webdriver .chromium .webdriver import ChromiumDriver
1919from selenium .webdriver .common .desired_capabilities import DesiredCapabilities
20- from selenium .webdriver .common .driver_finder import DriverFinder
2120
2221from .options import Options
2322from .service import Service
@@ -40,16 +39,13 @@ def __init__(
4039 - service - Service object for handling the browser driver if you need to pass extra details
4140 - keep_alive - Whether to configure EdgeRemoteConnection to use HTTP keep-alive.
4241 """
43- self .service = service if service else Service ()
44- self .options = options if options else Options ()
45- self .keep_alive = keep_alive
46-
47- self .service .path = DriverFinder .get_path (self .service , self .options )
42+ service = service if service else Service ()
43+ options = options if options else Options ()
4844
4945 super ().__init__ (
5046 DesiredCapabilities .EDGE ["browserName" ],
5147 "ms" ,
52- self . options ,
53- self . service ,
54- self . keep_alive ,
48+ options ,
49+ service ,
50+ keep_alive ,
5551 )
Original file line number Diff line number Diff line change 2222from selenium .webdriver .common import service
2323from selenium .webdriver .common import utils
2424
25- DEFAULT_EXECUTABLE_PATH = "geckodriver"
26-
2725
2826class Service (service .Service ):
2927 """A Service class that is responsible for the starting and stopping of
@@ -39,7 +37,7 @@ class Service(service.Service):
3937
4038 def __init__ (
4139 self ,
42- executable_path : str = DEFAULT_EXECUTABLE_PATH ,
40+ executable_path : str = None ,
4341 port : int = 0 ,
4442 service_args : typing .Optional [typing .List [str ]] = None ,
4543 log_path : typing .Optional [str ] = None ,
Original file line number Diff line number Diff line change @@ -54,18 +54,17 @@ def __init__(
5454 """
5555
5656 self .service = service if service else Service ()
57- self .options = options if options else Options ()
58- self .keep_alive = keep_alive
57+ options = options if options else Options ()
5958
60- self .service .path = DriverFinder .get_path (self .service , self . options )
59+ self .service .path = DriverFinder .get_path (self .service , options )
6160 self .service .start ()
6261
6362 executor = FirefoxRemoteConnection (
6463 remote_server_addr = self .service .service_url ,
65- ignore_proxy = self . options ._ignore_local_proxy ,
66- keep_alive = self . keep_alive ,
64+ ignore_proxy = options ._ignore_local_proxy ,
65+ keep_alive = keep_alive ,
6766 )
68- super ().__init__ (command_executor = executor , options = self . options )
67+ super ().__init__ (command_executor = executor , options = options )
6968
7069 self ._is_remote = False
7170
You can’t perform that action at this time.
0 commit comments