Skip to content

Commit 066ea2b

Browse files
whimboojgraham
authored andcommitted
[wdspec] Session fixtures should not ignore "session not created" errors.
Right now we ignore all the possible thrown "session not created" errors unless the session id is not set. This is specifically problematic for the BiDi session creation, which would fail silently in case it cannot be created. Differential Revision: https://phabricator.services.mozilla.com/D122625 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1725683 gecko-commit: aca153106940b800cac068609f552fc82b2ba2d1 gecko-reviewers: webdriver-reviewers, jgraham
1 parent 3c6d55a commit 066ea2b

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

tools/webdriver/webdriver/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
from typing import Dict
2+
from urllib import parse as urlparse
3+
14
from . import error
25
from . import protocol
36
from . import transport
47
from .bidi.client import BidiSession
58

6-
from urllib import parse as urlparse
7-
89

910
def command(func):
1011
def inner(self, *args, **kwargs):
@@ -551,6 +552,9 @@ def start(self):
551552
body["capabilities"] = self.requested_capabilities
552553

553554
value = self.send_command("POST", "session", body=body)
555+
assert isinstance(value["sessionId"], str)
556+
assert isinstance(value["capabilities"], Dict)
557+
554558
self.session_id = value["sessionId"]
555559
self.capabilities = value["capabilities"]
556560

webdriver/tests/support/fixtures.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,8 @@ async def session(capabilities, configuration, request):
113113
configuration["host"],
114114
configuration["port"],
115115
capabilities=caps)
116-
try:
117-
_current_session.start()
118116

119-
except webdriver.error.SessionNotCreatedException:
120-
if not _current_session.session_id:
121-
raise
117+
_current_session.start()
122118

123119
# Enforce a fixed default window size and position
124120
if _current_session.capabilities.get("setWindowRect"):
@@ -159,12 +155,8 @@ async def bidi_session(capabilities, configuration, request):
159155
capabilities=caps,
160156
enable_bidi=True)
161157

162-
try:
163-
_current_session.start()
164-
await _current_session.bidi_session.start()
165-
except webdriver.error.SessionNotCreatedException:
166-
if not _current_session.session_id:
167-
raise
158+
_current_session.start()
159+
await _current_session.bidi_session.start()
168160

169161
# Enforce a fixed default window size and position
170162
_current_session.window.size = defaults.WINDOW_SIZE

0 commit comments

Comments
 (0)