Skip to content

Commit 4096f77

Browse files
authored
Merge pull request #1856 from emanlove/remote-browser-without-options-1855
Remote browser without options 1855
2 parents f3caca2 + e6aff34 commit 4096f77

File tree

2 files changed

+48
-30
lines changed

2 files changed

+48
-30
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
*** Settings ***
2+
Library SeleniumLibrary
3+
Library Process
4+
5+
*** Variables ***
6+
${URL} https://robotframework.org/
7+
${REMOTE_BETA} http://localhost:7272
8+
9+
*** Test Cases ***
10+
Open Chrome with Remote Webdriver without Options
11+
# [Setup] StartDriver chromedriver
12+
Open Browser
13+
... url=${URL}
14+
... browser=chrome
15+
... remote_url=${REMOTE_BETA}
16+
# [Teardown] Stop Driver
17+
18+
Open Edge with Remote Webdriver without Options
19+
# [Setup] StartDriver msedgedriver
20+
Open Browser
21+
... url=${URL}
22+
... browser=edge
23+
... remote_url=${REMOTE_BETA}
24+
# [Teardown] Stop Driver
25+
26+
*** Keywords ***
27+
Start Driver
28+
[Arguments] ${driver_cmd}
29+
Start Process ${driver_cmd} --port:7272
30+
${result}= Wait For Process timeout=30secs
31+
Process Should Be Running error_message=Unable to start driver with command ${driver_cmd}
32+
33+
Stop Driver
34+
Terminate Process

src/SeleniumLibrary/keywords/webdrivertools/webdrivertools.py

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,9 @@ def create_chrome(
140140
executable_path="chromedriver",
141141
):
142142
if remote_url:
143-
defaul_caps = webdriver.DesiredCapabilities.CHROME.copy()
144-
desired_capabilities = self._remote_capabilities_resolver(
145-
desired_capabilities, defaul_caps
146-
)
147-
return self._remote(desired_capabilities, remote_url, options=options)
143+
if not options:
144+
options = webdriver.ChromeOptions()
145+
return self._remote(remote_url, options=options)
148146
if not executable_path:
149147
executable_path = self._get_executable_path(webdriver.chrome.service.Service)
150148
service = ChromeService(executable_path=executable_path, log_path=service_log_path)
@@ -196,11 +194,7 @@ def create_firefox(
196194
# as to attach the profile to it. If there a scenario in which we don't want to do this???
197195

198196
if remote_url:
199-
default_caps = webdriver.DesiredCapabilities.FIREFOX.copy()
200-
desired_capabilities = self._remote_capabilities_resolver(
201-
desired_capabilities, default_caps
202-
)
203-
return self._remote(desired_capabilities, remote_url, profile, options)
197+
return self._remote(remote_url, options)
204198
service_log_path = (
205199
service_log_path if service_log_path else self._geckodriver_log
206200
)
@@ -209,9 +203,7 @@ def create_firefox(
209203
service = FirefoxService(executable_path=executable_path, log_path=service_log_path)
210204
return webdriver.Firefox(
211205
options=options,
212-
#firefox_profile=profile, # need to move
213206
service=service,
214-
#**desired_capabilities,
215207
)
216208

217209
def _get_ff_profile(self, ff_profile_dir):
@@ -271,11 +263,9 @@ def create_ie(
271263
executable_path="IEDriverServer.exe",
272264
):
273265
if remote_url:
274-
defaul_caps = webdriver.DesiredCapabilities.INTERNETEXPLORER.copy()
275-
desired_capabilities = self._remote_capabilities_resolver(
276-
desired_capabilities, defaul_caps
277-
)
278-
return self._remote(desired_capabilities, remote_url, options=options)
266+
if not options:
267+
options = webdriver.IeOptions()
268+
return self._remote(remote_url, options=options)
279269
if not executable_path:
280270
executable_path = self._get_executable_path(webdriver.ie.service.Service)
281271
service = IeService(executable_path=executable_path, log_path=service_log_path)
@@ -298,11 +288,9 @@ def create_edge(
298288
executable_path="msedgedriver",
299289
):
300290
if remote_url:
301-
defaul_caps = webdriver.DesiredCapabilities.EDGE.copy()
302-
desired_capabilities = self._remote_capabilities_resolver(
303-
desired_capabilities, defaul_caps
304-
)
305-
return self._remote(desired_capabilities, remote_url, options=options)
291+
if not options:
292+
options = webdriver.EdgeOptions()
293+
return self._remote(remote_url, options=options)
306294
if not executable_path:
307295
executable_path = self._get_executable_path(webdriver.edge.service.Service)
308296
service = EdgeService(executable_path=executable_path, log_path=service_log_path)
@@ -321,25 +309,21 @@ def create_safari(
321309
executable_path="/usr/bin/safaridriver",
322310
):
323311
if remote_url:
324-
defaul_caps = webdriver.DesiredCapabilities.SAFARI.copy()
325-
desired_capabilities = self._remote_capabilities_resolver(
326-
desired_capabilities, defaul_caps
327-
)
328-
return self._remote(desired_capabilities, remote_url, options=options)
312+
if not options:
313+
options = webdriver.SafariOptions()
314+
return self._remote(remote_url, options=options)
329315
if not executable_path:
330316
executable_path = self._get_executable_path(webdriver.Safari)
331317
service = SafariService(executable_path=executable_path, log_path=service_log_path)
332318
return webdriver.Safari(options=options, service=service)
333319

334-
def _remote(self, desired_capabilities, remote_url, profile_dir=None, options=None):
320+
def _remote(self, remote_url, options):
335321
remote_url = str(remote_url)
336322
file_detector = self._get_sl_file_detector()
337323
return webdriver.Remote(
338324
command_executor=remote_url,
339-
# browser_profile=profile_dir,
340325
options=options,
341326
file_detector=file_detector,
342-
# **desired_capabilities,
343327
)
344328

345329
def _get_sl_file_detector(self):

0 commit comments

Comments
 (0)