File tree Expand file tree Collapse file tree 15 files changed +48
-78
lines changed
test/selenium/webdriver/common Expand file tree Collapse file tree 15 files changed +48
-78
lines changed Original file line number Diff line number Diff line change 19
19
from selenium .types import SubprocessStdAlias
20
20
from selenium .webdriver .chromium import service
21
21
22
- DEFAULT_EXECUTABLE_PATH = "chromedriver"
23
-
24
22
25
23
class Service (service .ChromiumService ):
26
24
"""A Service class that is responsible for the starting and stopping of
@@ -35,7 +33,7 @@ class Service(service.ChromiumService):
35
33
36
34
def __init__ (
37
35
self ,
38
- executable_path : str = DEFAULT_EXECUTABLE_PATH ,
36
+ executable_path = None ,
39
37
port : int = 0 ,
40
38
service_args : typing .Optional [typing .List [str ]] = None ,
41
39
log_path : typing .Optional [str ] = None ,
Original file line number Diff line number Diff line change 17
17
18
18
from selenium .webdriver .chromium .webdriver import ChromiumDriver
19
19
from selenium .webdriver .common .desired_capabilities import DesiredCapabilities
20
- from selenium .webdriver .common .driver_finder import DriverFinder
21
20
22
21
from .options import Options
23
22
from .service import Service
@@ -40,16 +39,13 @@ def __init__(
40
39
- service - Service object for handling the browser driver if you need to pass extra details
41
40
- keep_alive - Whether to configure ChromeRemoteConnection to use HTTP keep-alive.
42
41
"""
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 ()
48
44
49
45
super ().__init__ (
50
46
DesiredCapabilities .CHROME ["browserName" ],
51
47
"goog" ,
52
- self . options ,
53
- self . service ,
54
- self . keep_alive ,
48
+ options ,
49
+ service ,
50
+ keep_alive ,
55
51
)
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class ChromiumService(service.Service):
37
37
38
38
def __init__ (
39
39
self ,
40
- executable_path : str ,
40
+ executable_path : str = None ,
41
41
port : int = 0 ,
42
42
service_args : typing .Optional [typing .List [str ]] = None ,
43
43
log_path : typing .Optional [str ] = None ,
Original file line number Diff line number Diff line change 16
16
# under the License.
17
17
18
18
from selenium .webdriver .chromium .remote_connection import ChromiumRemoteConnection
19
+ from selenium .webdriver .common .driver_finder import DriverFinder
19
20
from selenium .webdriver .common .options import ArgOptions
20
21
from selenium .webdriver .common .service import Service
21
22
from selenium .webdriver .remote .webdriver import WebDriver as RemoteWebDriver
@@ -46,7 +47,8 @@ def __init__(
46
47
self .vendor_prefix = vendor_prefix
47
48
48
49
self .service = service
49
- self .options = options
50
+
51
+ self .service .path = DriverFinder .get_path (self .service , options )
50
52
51
53
self .service .start ()
52
54
@@ -57,9 +59,9 @@ def __init__(
57
59
browser_name = browser_name ,
58
60
vendor_prefix = vendor_prefix ,
59
61
keep_alive = keep_alive ,
60
- ignore_proxy = self . options ._ignore_local_proxy ,
62
+ ignore_proxy = options ._ignore_local_proxy ,
61
63
),
62
- options = self . options ,
64
+ options = options ,
63
65
)
64
66
except Exception :
65
67
self .quit ()
Original file line number Diff line number Diff line change 15
15
# specific language governing permissions and limitations
16
16
# under the License.
17
17
import logging
18
- import shutil
19
18
from pathlib import Path
20
19
21
20
from selenium .common .exceptions import NoSuchDriverException
@@ -34,13 +33,14 @@ class DriverFinder:
34
33
35
34
@staticmethod
36
35
def get_path (service : Service , options : BaseOptions ) -> str :
37
- path = shutil . which ( service .path )
36
+ path = service .path
38
37
try :
39
38
path = SeleniumManager ().driver_location (options ) if path is None else path
40
39
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 )
42
42
43
43
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' ] } " )
45
45
46
46
return path
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ class Service(ABC):
50
50
51
51
def __init__ (
52
52
self ,
53
- executable : str ,
53
+ executable : str = None ,
54
54
port : int = 0 ,
55
55
log_file : SubprocessStdAlias = None ,
56
56
log_output : SubprocessStdAlias = None ,
Original file line number Diff line number Diff line change 20
20
from selenium .types import SubprocessStdAlias
21
21
from selenium .webdriver .chromium import service
22
22
23
- DEFAULT_EXECUTABLE_PATH = "msedgedriver"
24
-
25
23
26
24
class Service (service .ChromiumService ):
27
25
"""A Service class that is responsible for the starting and stopping of
@@ -38,7 +36,7 @@ class Service(service.ChromiumService):
38
36
39
37
def __init__ (
40
38
self ,
41
- executable_path : str = DEFAULT_EXECUTABLE_PATH ,
39
+ executable_path : str = None ,
42
40
port : int = 0 ,
43
41
verbose : bool = False ,
44
42
log_path : typing .Optional [str ] = None ,
Original file line number Diff line number Diff line change 17
17
18
18
from selenium .webdriver .chromium .webdriver import ChromiumDriver
19
19
from selenium .webdriver .common .desired_capabilities import DesiredCapabilities
20
- from selenium .webdriver .common .driver_finder import DriverFinder
21
20
22
21
from .options import Options
23
22
from .service import Service
@@ -40,16 +39,13 @@ def __init__(
40
39
- service - Service object for handling the browser driver if you need to pass extra details
41
40
- keep_alive - Whether to configure EdgeRemoteConnection to use HTTP keep-alive.
42
41
"""
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 ()
48
44
49
45
super ().__init__ (
50
46
DesiredCapabilities .EDGE ["browserName" ],
51
47
"ms" ,
52
- self . options ,
53
- self . service ,
54
- self . keep_alive ,
48
+ options ,
49
+ service ,
50
+ keep_alive ,
55
51
)
Original file line number Diff line number Diff line change 22
22
from selenium .webdriver .common import service
23
23
from selenium .webdriver .common import utils
24
24
25
- DEFAULT_EXECUTABLE_PATH = "geckodriver"
26
-
27
25
28
26
class Service (service .Service ):
29
27
"""A Service class that is responsible for the starting and stopping of
@@ -39,7 +37,7 @@ class Service(service.Service):
39
37
40
38
def __init__ (
41
39
self ,
42
- executable_path : str = DEFAULT_EXECUTABLE_PATH ,
40
+ executable_path : str = None ,
43
41
port : int = 0 ,
44
42
service_args : typing .Optional [typing .List [str ]] = None ,
45
43
log_path : typing .Optional [str ] = None ,
Original file line number Diff line number Diff line change @@ -54,18 +54,17 @@ def __init__(
54
54
"""
55
55
56
56
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 ()
59
58
60
- self .service .path = DriverFinder .get_path (self .service , self . options )
59
+ self .service .path = DriverFinder .get_path (self .service , options )
61
60
self .service .start ()
62
61
63
62
executor = FirefoxRemoteConnection (
64
63
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 ,
67
66
)
68
- super ().__init__ (command_executor = executor , options = self . options )
67
+ super ().__init__ (command_executor = executor , options = options )
69
68
70
69
self ._is_remote = False
71
70
You can’t perform that action at this time.
0 commit comments