Skip to content

Commit

Permalink
[py] Re-enabling console differentiation when listening for console logs
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomatedTester committed Nov 27, 2020
1 parent 691de4f commit b1f8773
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion py/selenium/webdriver/remote/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1527,13 +1527,17 @@ async def add_listener(self, event_type):
await session.execute(devtools.runtime.enable())
console = {
"message": None,
"level": None
}
async with session.wait_for(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:
console["message"] = messages.value.args[0].value
# console["level"] = messages.value.message.level
console["level"] = messages.value.args[0].type_

@asynccontextmanager
async def _get_bidi_connection(self):
Expand Down
16 changes: 8 additions & 8 deletions py/test/selenium/webdriver/common/bidi_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ async def test_check_console_messages(driver, pages):
assert messages["message"] == "I love cheese"


# Disabling for now after moving to Runtime APIs for console messages
# async def test_check_error_console_messages(driver, pages):
# pages.load("javascriptPage.html")
# from selenium.webdriver.common.bidi.console import Console
# async with driver.add_listener(Console.ERROR) as messages:
# driver.execute_script("console.error(\"I don't cheese\")")
# driver.execute_script("console.log('I love cheese')")
# assert messages["message"] == "I don't cheese"
async def test_check_error_console_messages(driver, pages):
pages.load("javascriptPage.html")
from selenium.webdriver.common.bidi.console import Console
async with driver.add_listener(Console.ERROR) as messages:
driver.execute_script("console.error(\"I don't cheese\")")
driver.execute_script("console.log('I love cheese')")
assert messages["message"] == "I don't cheese"


@pytest.mark.xfail_firefox
@pytest.mark.xfail_safari
Expand Down

0 comments on commit b1f8773

Please sign in to comment.