Skip to content

Commit 5b1b449

Browse files
authored
[py] filter which bidi logs are recorded based on event type (#12951)
* [py] filter which bidi logs are recorded based on event type Allows user to specify the event type as Console Log Still only allows capturing the first event whatever it is
1 parent 123bb67 commit 5b1b449

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

py/selenium/webdriver/common/log.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,6 @@ async def add_listener(self, event_type) -> dict:
138138
async with session.wait_for(self.devtools.runtime.ConsoleAPICalled) as messages:
139139
yield console
140140

141-
if event_type == Console.ERROR:
142-
console["message"] = messages.value.args[0].value
143-
console["level"] = messages.value.args[0].type_
144-
if event_type == Console.ALL:
141+
if event_type == Console.ALL or event_type.value == messages.value.type_:
145142
console["message"] = messages.value.args[0].value
146143
console["level"] = messages.value.args[0].type_

py/test/selenium/webdriver/common/bidi_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async def test_check_console_messages(driver, pages):
3131
pages.load("javascriptPage.html")
3232
from selenium.webdriver.common.bidi.console import Console
3333

34-
async with log.add_listener(Console.ALL) as messages:
34+
async with log.add_listener(Console.LOG) as messages:
3535
driver.execute_script("console.log('I love cheese')")
3636
assert messages["message"] == "I love cheese"
3737

0 commit comments

Comments
 (0)