Skip to content

Commit c779fd2

Browse files
authored
Merge branch 'trunk' into fix-mypy-type-errors-2
2 parents aadee6d + abd2160 commit c779fd2

File tree

4 files changed

+64
-43
lines changed

4 files changed

+64
-43
lines changed

common/repositories.bzl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def pin_browsers():
1111

1212
http_archive(
1313
name = "linux_firefox",
14-
url = "https://ftp.mozilla.org/pub/firefox/releases/139.0.1/linux-x86_64/en-US/firefox-139.0.1.tar.xz",
15-
sha256 = "f1a264f61d41700e8fcfa2310478d0c909655399a413072664fddaf612b53c07",
14+
url = "https://ftp.mozilla.org/pub/firefox/releases/139.0.4/linux-x86_64/en-US/firefox-139.0.4.tar.xz",
15+
sha256 = "fe22686f09a0c46390fea430b26cccc323d92af26869699f394f25b5e71527a3",
1616
build_file_content = """
1717
load("@aspect_rules_js//js:defs.bzl", "js_library")
1818
package(default_visibility = ["//visibility:public"])
@@ -33,8 +33,8 @@ js_library(
3333

3434
dmg_archive(
3535
name = "mac_firefox",
36-
url = "https://ftp.mozilla.org/pub/firefox/releases/139.0.1/mac/en-US/Firefox%20139.0.1.dmg",
37-
sha256 = "243478e2a2fd5d9dd0cc261c812b0146e433d703fec960c27c7284b2de7e65bc",
36+
url = "https://ftp.mozilla.org/pub/firefox/releases/139.0.4/mac/en-US/Firefox%20139.0.4.dmg",
37+
sha256 = "fc058bf34094828c0919ad81672d697cf01dfa291ba9b11e0b1c119588878405",
3838
build_file_content = """
3939
load("@aspect_rules_js//js:defs.bzl", "js_library")
4040
package(default_visibility = ["//visibility:public"])
@@ -199,8 +199,8 @@ js_library(
199199

200200
http_archive(
201201
name = "linux_chrome",
202-
url = "https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.68/linux64/chrome-linux64.zip",
203-
sha256 = "5e92980724bb8577964d6914a6faa8021ff9b640944673e9b5fcb6eccfc16c8e",
202+
url = "https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.70/linux64/chrome-linux64.zip",
203+
sha256 = "da1424d975dbe963b0a7f7f8e8c2e477bfed6b3430a2bc0b287f1c247ec62ee3",
204204
build_file_content = """
205205
load("@aspect_rules_js//js:defs.bzl", "js_library")
206206
package(default_visibility = ["//visibility:public"])
@@ -221,8 +221,8 @@ js_library(
221221

222222
http_archive(
223223
name = "mac_chrome",
224-
url = "https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.68/mac-x64/chrome-mac-x64.zip",
225-
sha256 = "d15327182bee2493286f5f0c526ab6efb7888944d6714ffba5b67997e6c1af93",
224+
url = "https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.70/mac-x64/chrome-mac-x64.zip",
225+
sha256 = "2ea79a9457dbaffae6fbdf592c93776ac859dca98b448f7513cdd68234454a07",
226226
strip_prefix = "chrome-mac-x64",
227227
patch_cmds = [
228228
"mv 'Google Chrome for Testing.app' Chrome.app",
@@ -243,8 +243,8 @@ js_library(
243243

244244
http_archive(
245245
name = "linux_chromedriver",
246-
url = "https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.68/linux64/chromedriver-linux64.zip",
247-
sha256 = "05e356b3dd497a26f5e3412c67b59976853458f1b3aa5b2b9f606cecdf922586",
246+
url = "https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.70/linux64/chromedriver-linux64.zip",
247+
sha256 = "cade69e8d67f4951049e56d796111755e0bf9240d26378975a95c8423bb3f55a",
248248
strip_prefix = "chromedriver-linux64",
249249
build_file_content = """
250250
load("@aspect_rules_js//js:defs.bzl", "js_library")
@@ -261,8 +261,8 @@ js_library(
261261

262262
http_archive(
263263
name = "mac_chromedriver",
264-
url = "https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.68/mac-x64/chromedriver-mac-x64.zip",
265-
sha256 = "f369406a48ca98edfc1845e3900be039ab4c93deabe941288514bb402631a5c1",
264+
url = "https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.70/mac-x64/chromedriver-mac-x64.zip",
265+
sha256 = "d80825e87543d99ad7a8b9356fb236ddb7df3ba087f8f314991195da27a7ccc3",
266266
strip_prefix = "chromedriver-mac-x64",
267267
build_file_content = """
268268
load("@aspect_rules_js//js:defs.bzl", "js_library")

py/conftest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,19 @@ def clean_driver(request):
443443
except (AttributeError, TypeError):
444444
raise Exception("This test requires a --driver to be specified.")
445445
driver_reference = getattr(webdriver, driver_class)
446+
447+
# conditionally mark tests as expected to fail based on driver
448+
marker = request.node.get_closest_marker(f"xfail_{driver_class.lower()}")
449+
if marker is not None:
450+
if "run" in marker.kwargs:
451+
if marker.kwargs["run"] is False:
452+
pytest.skip()
453+
yield
454+
return
455+
if "raises" in marker.kwargs:
456+
marker.kwargs.pop("raises")
457+
pytest.xfail(**marker.kwargs)
458+
446459
yield driver_reference
447460
if request.node.get_closest_marker("no_driver_after_test"):
448461
driver_reference = None

py/selenium/webdriver/remote/webdriver.py

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
1817
"""The WebDriver implementation."""
1918

2019
import base64
@@ -75,7 +74,6 @@
7574
from .websocket_connection import WebSocketConnection
7675

7776
cdp = None
78-
devtools = None
7977

8078

8179
def import_cdp():
@@ -267,6 +265,7 @@ def __init__(
267265
self._storage = None
268266
self._webextension = None
269267
self._permissions = None
268+
self._devtools = None
270269

271270
def __repr__(self):
272271
return f'<{type(self).__module__}.{type(self).__name__} (session="{self.session_id}")>'
@@ -1182,32 +1181,28 @@ def orientation(self, value) -> None:
11821181
raise WebDriverException("You can only set the orientation to 'LANDSCAPE' and 'PORTRAIT'")
11831182

11841183
def start_devtools(self):
1185-
global devtools
1186-
if self._websocket_connection:
1187-
return devtools, self._websocket_connection
1184+
global cdp
1185+
import_cdp()
1186+
if self.caps.get("se:cdp"):
1187+
ws_url = self.caps.get("se:cdp")
1188+
version = self.caps.get("se:cdpVersion").split(".")[0]
11881189
else:
1189-
global cdp
1190-
import_cdp()
1191-
1192-
if not devtools:
1193-
if self.caps.get("se:cdp"):
1194-
ws_url = self.caps.get("se:cdp")
1195-
version = self.caps.get("se:cdpVersion").split(".")[0]
1196-
else:
1197-
version, ws_url = self._get_cdp_details()
1198-
1199-
if not ws_url:
1200-
raise WebDriverException("Unable to find url to connect to from capabilities")
1201-
1202-
devtools = cdp.import_devtools(version)
1203-
if self.caps["browserName"].lower() == "firefox":
1204-
raise RuntimeError("CDP support for Firefox has been removed. Please switch to WebDriver BiDi.")
1205-
self._websocket_connection = WebSocketConnection(ws_url)
1206-
targets = self._websocket_connection.execute(devtools.target.get_targets())
1207-
target_id = targets[0].target_id
1208-
session = self._websocket_connection.execute(devtools.target.attach_to_target(target_id, True))
1209-
self._websocket_connection.session_id = session
1210-
return devtools, self._websocket_connection
1190+
version, ws_url = self._get_cdp_details()
1191+
1192+
if not ws_url:
1193+
raise WebDriverException("Unable to find url to connect to from capabilities")
1194+
1195+
self._devtools = cdp.import_devtools(version)
1196+
if self._websocket_connection:
1197+
return self._devtools, self._websocket_connection
1198+
if self.caps["browserName"].lower() == "firefox":
1199+
raise RuntimeError("CDP support for Firefox has been removed. Please switch to WebDriver BiDi.")
1200+
self._websocket_connection = WebSocketConnection(ws_url)
1201+
targets = self._websocket_connection.execute(self._devtools.target.get_targets())
1202+
target_id = targets[0].target_id
1203+
session = self._websocket_connection.execute(self._devtools.target.attach_to_target(target_id, True))
1204+
self._websocket_connection.session_id = session
1205+
return self._devtools, self._websocket_connection
12111206

12121207
@asynccontextmanager
12131208
async def bidi_connection(self):
@@ -1282,9 +1277,8 @@ def browser(self):
12821277

12831278
@property
12841279
def _session(self):
1285-
"""
1286-
Returns the BiDi session object for the current WebDriver session.
1287-
"""
1280+
"""Returns the BiDi session object for the current WebDriver
1281+
session."""
12881282
if not self._websocket_connection:
12891283
self._start_bidi()
12901284

@@ -1295,7 +1289,8 @@ def _session(self):
12951289

12961290
@property
12971291
def browsing_context(self):
1298-
"""Returns a browsing context module object for BiDi browsing context commands.
1292+
"""Returns a browsing context module object for BiDi browsing context
1293+
commands.
12991294
13001295
Returns:
13011296
--------

py/test/selenium/webdriver/common/devtools_tests.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,16 @@ def test_check_console_messages(driver, pages, recwarn):
3838
assert console_api_calls[0].args[0].value == "I love cheese"
3939
assert console_api_calls[1].type_ == "error"
4040
assert console_api_calls[1].args[0].value == "I love bread"
41+
42+
43+
@pytest.mark.xfail_safari
44+
@pytest.mark.xfail_firefox
45+
@pytest.mark.xfail_remote
46+
def test_check_start_twice(clean_driver, clean_options):
47+
driver1 = clean_driver(options=clean_options)
48+
devtools1, connection1 = driver1.start_devtools()
49+
driver1.quit()
50+
51+
driver2 = clean_driver(options=clean_options)
52+
devtools2, connection2 = driver2.start_devtools()
53+
driver2.quit()

0 commit comments

Comments
 (0)