-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathtest_logs.py
26 lines (18 loc) · 979 Bytes
/
test_logs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import pytest
from selenium.webdriver.common.bidi.console import Console
from selenium.webdriver.common.by import By
from selenium.webdriver.common.log import Log
@pytest.mark.trio
async def test_console_log(driver):
driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html')
async with driver.bidi_connection() as session:
async with Log(driver, session).add_listener(Console.ALL) as messages:
driver.find_element(by=By.ID, value='consoleLog').click()
assert messages["message"] == "Hello, world!"
@pytest.mark.trio
async def test_js_error(driver):
driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html')
async with driver.bidi_connection() as session:
async with Log(driver, session).add_js_error_listener() as messages:
driver.find_element(by=By.ID, value='jsException').click()
assert "Error: Not working" in messages.exception_details.exception.description