Path: blob/trunk/py/test/selenium/webdriver/common/devtools_tests.py
1865 views
# Licensed to the Software Freedom Conservancy (SFC) under one1# or more contributor license agreements. See the NOTICE file2# distributed with this work for additional information3# regarding copyright ownership. The SFC licenses this file4# to you under the Apache License, Version 2.0 (the5# "License"); you may not use this file except in compliance6# with the License. You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing,11# software distributed under the License is distributed on an12# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13# KIND, either express or implied. See the License for the14# specific language governing permissions and limitations15# under the License.16import pytest1718from selenium.webdriver.support.ui import WebDriverWait192021@pytest.mark.xfail_safari22@pytest.mark.xfail_firefox23@pytest.mark.xfail_remote24def test_check_console_messages(driver, pages, recwarn):25devtools, connection = driver.start_devtools()26console_api_calls = []2728assert len(recwarn) == 02930connection.execute(devtools.runtime.enable())31connection.on(devtools.runtime.ConsoleAPICalled, console_api_calls.append)32driver.execute_script("console.log('I love cheese')")33driver.execute_script("console.error('I love bread')")34WebDriverWait(driver, 10).until(lambda _: len(console_api_calls) == 2)3536assert console_api_calls[0].type_ == "log"37assert console_api_calls[0].args[0].value == "I love cheese"38assert console_api_calls[1].type_ == "error"39assert console_api_calls[1].args[0].value == "I love bread"404142@pytest.mark.xfail_safari43@pytest.mark.xfail_firefox44@pytest.mark.xfail_remote45def test_check_start_twice(clean_driver, clean_options):46driver1 = clean_driver(options=clean_options)47devtools1, connection1 = driver1.start_devtools()48driver1.quit()4950driver2 = clean_driver(options=clean_options)51devtools2, connection2 = driver2.start_devtools()52driver2.quit()535455