@@ -13,6 +13,7 @@ def launch_driver(driver_name=settings.DRIVER, desired_capabilities=None):
13
13
driver_name : Name of WebDriver to use
14
14
desired_capabilities : Desired browser specs
15
15
"""
16
+ driver = None
16
17
17
18
try :
18
19
driver_cls = getattr (webdriver , driver_name )
@@ -39,11 +40,6 @@ def launch_driver(driver_name=settings.DRIVER, desired_capabilities=None):
39
40
# Append "Selenium Bot" to the existing user agent
40
41
custom_user_agent = f'{ default_user_agent } OSF Selenium Bot'
41
42
42
- # NOTE: BrowserStack does support the use of Chrome Options, but we are not
43
- # currently using any of them. Below are several steps to setup preferences
44
- # that are specific to Firefox. Currently when running Chrome or Edge in
45
- # BrowserStack we are running with the default base install options.
46
-
47
43
from selenium .webdriver .firefox .options import Options
48
44
49
45
ffo = Options ()
@@ -110,9 +106,10 @@ def launch_driver(driver_name=settings.DRIVER, desired_capabilities=None):
110
106
desired_capabilities = desired_capabilities ,
111
107
options = chrome_options ,
112
108
)
113
-
114
- print (driver .execute_script (DESIRED_CAP ))
115
- print (driver .execute_script ('return navigator.userAgent;' ))
109
+ elif settings .BUILD == 'edge' :
110
+ # Use default settings for edge driver
111
+ # We can update this once we upgrade to selenium v4
112
+ driver = webdriver .Edge ()
116
113
117
114
elif driver_name == 'Chrome' and settings .HEADLESS :
118
115
from selenium .webdriver .chrome .options import Options
@@ -156,6 +153,11 @@ def launch_driver(driver_name=settings.DRIVER, desired_capabilities=None):
156
153
else :
157
154
driver = driver_cls ()
158
155
156
+ if driver is None :
157
+ raise RuntimeError (
158
+ 'WebDriver could not be instantiated based on provided configuration.'
159
+ )
160
+
159
161
driver .maximize_window ()
160
162
return driver
161
163
0 commit comments