Skip to content

Commit

Permalink
[py] Pin Firefox bidi support to use the generated code for CDP 85
Browse files Browse the repository at this point in the history
The Mozilla team are trying add support and there was a breaking
change to the protocol between version.
  • Loading branch information
AutomatedTester committed Dec 17, 2020
1 parent f86f6f9 commit 9a98924
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 11 additions & 3 deletions py/selenium/webdriver/remote/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

cdp = None


def import_cdp():
global cdp
if not cdp:
Expand Down Expand Up @@ -307,7 +308,7 @@ def start_session(self, capabilities, browser_profile=None):
self.caps = response.get('capabilities')

# Double check to see if we have a W3C Compliant browser
self.w3c = not response.get('status') #using not automatically results in boolean
self.w3c = not response.get('status') # using not automatically results in boolean
self.command_executor.w3c = self.w3c

def _wrap_value(self, value):
Expand Down Expand Up @@ -887,7 +888,7 @@ def minimize_window(self):
"""
self.execute(Command.MINIMIZE_WINDOW)

def print_page(self, print_options = None):
def print_page(self, print_options=None):
"""
Takes PDF of the current page.
The driver makes a best effort to return a PDF based on the provided parameters.
Expand Down Expand Up @@ -1577,9 +1578,11 @@ def _get_cdp_details(self):
import urllib3

http = urllib3.PoolManager()
_firefox = False
if self.caps.get("browserName") == "chrome":
debugger_address = self.caps.get(f"{self.vendor_prefix}:{self.caps.get('browserName')}Options").get("debuggerAddress")
else:
_firefox = True
debugger_address = self.caps.get("moz:debuggerAddress")
res = http.request('GET', f"http://{debugger_address}/json/version")
data = json.loads(res.data)
Expand All @@ -1588,6 +1591,11 @@ def _get_cdp_details(self):
websocket_url = data.get("webSocketDebuggerUrl")

import re
version = re.search(r".*/(\d+)\.", browser_version).group(1)
if _firefox:
# Mozilla Automation Team asked to only support 85
# until WebDriver Bidi is available.
version = 85
else:
version = re.search(r".*/(\d+)\.", browser_version).group(1)

return version, websocket_url
2 changes: 0 additions & 2 deletions py/test/selenium/webdriver/common/bidi_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import pytest


@pytest.mark.xfail_firefox
@pytest.mark.xfail_safari
async def test_check_console_messages(driver, pages):
pages.load("javascriptPage.html")
Expand All @@ -28,7 +27,6 @@ async def test_check_console_messages(driver, pages):
assert messages["message"] == "I love cheese"


@pytest.mark.xfail_firefox
@pytest.mark.xfail_safari
async def test_check_error_console_messages(driver, pages):
pages.load("javascriptPage.html")
Expand Down

0 comments on commit 9a98924

Please sign in to comment.