Skip to content

Commit

Permalink
[py] filter which bidi logs are recorded based on event type (#12951)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
titusfortner committed Dec 12, 2023
1 parent 123bb67 commit 5b1b449
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions py/selenium/webdriver/common/log.py
Expand Up @@ -138,9 +138,6 @@ async def add_listener(self, event_type) -> dict:
async with session.wait_for(self.devtools.runtime.ConsoleAPICalled) as messages:
yield console

if event_type == Console.ERROR:
console["message"] = messages.value.args[0].value
console["level"] = messages.value.args[0].type_
if event_type == Console.ALL:
if event_type == Console.ALL or event_type.value == messages.value.type_:
console["message"] = messages.value.args[0].value
console["level"] = messages.value.args[0].type_
2 changes: 1 addition & 1 deletion py/test/selenium/webdriver/common/bidi_tests.py
Expand Up @@ -31,7 +31,7 @@ async def test_check_console_messages(driver, pages):
pages.load("javascriptPage.html")
from selenium.webdriver.common.bidi.console import Console

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

Expand Down

0 comments on commit 5b1b449

Please sign in to comment.