Skip to content

Commit acbf749

Browse files
committed
[py] remote webdriver cannot match Chromium browser name for remote connection
1 parent 240e17b commit acbf749

File tree

6 files changed

+83
-5
lines changed

6 files changed

+83
-5
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
import typing
18+
19+
from selenium.webdriver import DesiredCapabilities
20+
from selenium.webdriver.chromium.remote_connection import ChromiumRemoteConnection
21+
22+
23+
class ChromeRemoteConnection(ChromiumRemoteConnection):
24+
browser_name = DesiredCapabilities.CHROME["browserName"]
25+
26+
def __init__(
27+
self,
28+
remote_server_addr: str,
29+
keep_alive: bool = True,
30+
ignore_proxy: typing.Optional[bool] = False,
31+
) -> None:
32+
super().__init__(
33+
remote_server_addr=remote_server_addr,
34+
vendor_prefix="goog",
35+
browser_name=ChromeRemoteConnection.browser_name,
36+
keep_alive=keep_alive,
37+
ignore_proxy=ignore_proxy,
38+
)

py/selenium/webdriver/chromium/remote_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(
2727
keep_alive: bool = True,
2828
ignore_proxy: bool = False,
2929
) -> None:
30-
super().__init__(remote_server_addr, keep_alive, ignore_proxy=ignore_proxy)
30+
super().__init__(remote_server_addr, keep_alive, ignore_proxy)
3131
self.browser_name = browser_name
3232
commands = self._remote_commands(vendor_prefix)
3333
for key, value in commands.items():
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
import typing
18+
19+
from selenium.webdriver import DesiredCapabilities
20+
from selenium.webdriver.chromium.remote_connection import ChromiumRemoteConnection
21+
22+
23+
class EdgeRemoteConnection(ChromiumRemoteConnection):
24+
browser_name = DesiredCapabilities.EDGE["browserName"]
25+
26+
def __init__(
27+
self,
28+
remote_server_addr: str,
29+
keep_alive: bool = True,
30+
ignore_proxy: typing.Optional[bool] = False,
31+
) -> None:
32+
super().__init__(
33+
remote_server_addr=remote_server_addr,
34+
vendor_prefix="goog",
35+
browser_name=EdgeRemoteConnection.browser_name,
36+
keep_alive=keep_alive,
37+
ignore_proxy=ignore_proxy,
38+
)

py/selenium/webdriver/firefox/remote_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class FirefoxRemoteConnection(RemoteConnection):
2323
browser_name = DesiredCapabilities.FIREFOX["browserName"]
2424

2525
def __init__(self, remote_server_addr, keep_alive=True, ignore_proxy=False) -> None:
26-
super().__init__(remote_server_addr, keep_alive, ignore_proxy=ignore_proxy)
26+
super().__init__(remote_server_addr, keep_alive, ignore_proxy)
2727

2828
self._commands["GET_CONTEXT"] = ("GET", "/session/$sessionId/moz/context")
2929
self._commands["SET_CONTEXT"] = ("POST", "/session/$sessionId/moz/context")

py/selenium/webdriver/remote/webdriver.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,12 @@ def _create_caps(caps):
9393

9494

9595
def get_remote_connection(capabilities, command_executor, keep_alive, ignore_local_proxy=False):
96-
from selenium.webdriver.chromium.remote_connection import ChromiumRemoteConnection
96+
from selenium.webdriver.chrome.remote_connection import ChromeRemoteConnection
97+
from selenium.webdriver.edge.remote_connection import EdgeRemoteConnection
9798
from selenium.webdriver.firefox.remote_connection import FirefoxRemoteConnection
9899
from selenium.webdriver.safari.remote_connection import SafariRemoteConnection
99100

100-
candidates = [RemoteConnection, ChromiumRemoteConnection, SafariRemoteConnection, FirefoxRemoteConnection]
101+
candidates = [ChromeRemoteConnection, EdgeRemoteConnection, SafariRemoteConnection, FirefoxRemoteConnection]
101102
handler = next((c for c in candidates if c.browser_name == capabilities.get("browserName")), RemoteConnection)
102103

103104
return handler(command_executor, keep_alive=keep_alive, ignore_proxy=ignore_local_proxy)

py/selenium/webdriver/safari/remote_connection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class SafariRemoteConnection(RemoteConnection):
2323
browser_name = DesiredCapabilities.SAFARI["browserName"]
2424

2525
def __init__(self, remote_server_addr: str, keep_alive: bool = True, ignore_proxy: bool = False) -> None:
26-
super().__init__(remote_server_addr, keep_alive, ignore_proxy=ignore_proxy)
26+
super().__init__(remote_server_addr, keep_alive, ignore_proxy)
27+
2728
self._commands["GET_PERMISSIONS"] = ("GET", "/session/$sessionId/apple/permissions")
2829
self._commands["SET_PERMISSIONS"] = ("POST", "/session/$sessionId/apple/permissions")
2930
self._commands["ATTACH_DEBUGGER"] = ("POST", "/session/$sessionId/apple/attach_debugger")

0 commit comments

Comments
 (0)