Skip to content

Commit 8b557aa

Browse files
committed
Executable path for Edge
1 parent d532450 commit 8b557aa

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

src/SeleniumLibrary/keywords/webdrivertools/webdrivertools.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,20 @@ def _has_options(self, web_driver):
205205
signature = inspect.getargspec(web_driver.__init__)
206206
return 'options' in signature.args
207207

208-
def create_edge(self, desired_capabilities, remote_url, options=None, service_log_path=None):
208+
def create_edge(self, desired_capabilities, remote_url, options=None, service_log_path=None,
209+
executable_path='MicrosoftWebDriver.exe'):
209210
if is_truthy(remote_url):
210211
defaul_caps = webdriver.DesiredCapabilities.EDGE.copy()
211212
desired_capabilities = self._remote_capabilities_resolver(desired_capabilities, defaul_caps)
212213
return self._remote(desired_capabilities, remote_url)
214+
if is_falsy(executable_path):
215+
executable_path = self._get_executable_path(webdriver.Edge)
213216
if self._has_options(webdriver.Edge):
214217
# options is supported from Selenium 4.0 onwards
215218
# If can be removed when minimum Selenium version is 4.0 or greater
216-
return webdriver.Edge(options=options, service_log_path=service_log_path, **desired_capabilities)
217-
return webdriver.Edge(service_log_path=service_log_path, **desired_capabilities)
219+
return webdriver.Edge(options=options, service_log_path=service_log_path, executable_path=executable_path,
220+
**desired_capabilities)
221+
return webdriver.Edge(service_log_path=service_log_path, executable_path=executable_path, **desired_capabilities)
218222

219223
def create_opera(self, desired_capabilities, remote_url, options=None, service_log_path=None):
220224
if is_truthy(remote_url):

utest/test/keywords/test_webdrivercreator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,9 @@ def test_ie_no_browser_name(creator):
393393

394394

395395
def test_edge(creator):
396+
executable_path = 'MicrosoftWebDriver.exe'
396397
expected_webdriver = mock()
397-
when(webdriver).Edge(service_log_path=None).thenReturn(expected_webdriver)
398+
when(webdriver).Edge(service_log_path=None, executable_path=executable_path).thenReturn(expected_webdriver)
398399
when(creator)._has_options(ANY).thenReturn(False)
399400
driver = creator.create_edge({}, None)
400401
assert driver == expected_webdriver

utest/test/keywords/test_webdrivercreator_executable_path.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ def test_get_executable_path(creator):
5555
executable_path = creator._get_executable_path(webdriver.Opera)
5656
assert executable_path == None
5757

58+
executable_path = creator._get_executable_path(webdriver.Edge)
59+
assert executable_path == 'MicrosoftWebDriver.exe'
60+
5861

5962
def test_create_chrome_executable_path_and_remote(creator):
6063
url = 'http://localhost:4444/wd/hub'
@@ -152,6 +155,25 @@ def test_create_ie_executable_path_not_set(creator):
152155
assert driver == expected_webdriver
153156

154157

158+
def test_create_edge_executable_path_set(creator):
159+
executable_path = '/path/to/MicrosoftWebDriver.exe'
160+
expected_webdriver = mock()
161+
when(webdriver).Edge(service_log_path=None,
162+
executable_path=executable_path).thenReturn(expected_webdriver)
163+
driver = creator.create_edge({}, None, executable_path=executable_path)
164+
assert driver == expected_webdriver
165+
166+
167+
def test_create_edge_executable_path_not_set(creator):
168+
executable_path = 'MicrosoftWebDriver.exe'
169+
expected_webdriver = mock()
170+
when(creator)._get_executable_path(ANY).thenReturn(executable_path)
171+
when(webdriver).Edge(service_log_path=None,
172+
executable_path=executable_path).thenReturn(expected_webdriver)
173+
driver = creator.create_edge({}, None, executable_path=None)
174+
assert driver == expected_webdriver
175+
176+
155177
def mock_file_detector(creator):
156178
file_detector = mock()
157179
when(creator)._get_sl_file_detector().thenReturn(file_detector)

utest/test/keywords/test_webdrivercreator_service_log_path.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,11 @@ def test_create_ie_with_service_log_path_real_path(creator):
137137

138138

139139
def test_create_edge_with_service_log_path_real_path(creator):
140+
executable_path = 'MicrosoftWebDriver.exe'
140141
log_file = os.path.join(creator.output_dir, 'ie-1.log')
141142
expected_webdriver = mock()
142143
when(creator.creator)._has_options(ANY).thenReturn(False)
143-
when(webdriver).Edge(service_log_path=log_file).thenReturn(expected_webdriver)
144+
when(webdriver).Edge(service_log_path=log_file, executable_path=executable_path).thenReturn(expected_webdriver)
144145
driver = creator.creator.create_edge({}, None, service_log_path=log_file)
145146
assert driver == expected_webdriver
146147

0 commit comments

Comments
 (0)