Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions py/selenium/webdriver/remote/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,10 @@ def start_devtools(self):
raise RuntimeError("CDP support for Firefox has been removed. Please switch to WebDriver BiDi.")
self._websocket_connection = WebSocketConnection(ws_url)
targets = self._websocket_connection.execute(self._devtools.target.get_targets())
target_id = targets[0].target_id
for target in targets:
if target.target_id == self.current_window_handle:
target_id = target.target_id
break
session = self._websocket_connection.execute(self._devtools.target.attach_to_target(target_id, True))
self._websocket_connection.session_id = session
return self._devtools, self._websocket_connection
Expand All @@ -1232,7 +1235,10 @@ async def bidi_connection(self):
devtools = cdp.import_devtools(version)
async with cdp.open_cdp(ws_url) as conn:
targets = await conn.execute(devtools.target.get_targets())
target_id = targets[0].target_id
for target in targets:
if target.target_id == self.current_window_handle:
target_id = target.target_id
break
async with conn.open_session(target_id) as session:
yield BidiConnection(session, cdp, devtools)

Expand Down Expand Up @@ -1423,7 +1429,7 @@ def _get_cdp_details(self):
try:
if self.caps.get("browserName") == "chrome":
debugger_address = self.caps.get("goog:chromeOptions").get("debuggerAddress")
elif self.caps.get("browserName") == "MicrosoftEdge":
elif self.caps.get("browserName") == "MicrosoftEdge" or self.caps.get("browserName") == "webview2":
debugger_address = self.caps.get("ms:edgeOptions").get("debuggerAddress")
except AttributeError:
raise WebDriverException("Can't get debugger address.")
Expand Down
Loading