Path: blob/trunk/py/test/selenium/webdriver/remote/remote_connection_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.1617import base641819import filetype20import pytest21from urllib3.exceptions import ReadTimeoutError2223from selenium import webdriver24from selenium.webdriver.common.by import By25from selenium.webdriver.remote.client_config import ClientConfig262728def test_browser_specific_method(driver, pages):29"""This only works on Firefox"""30pages.load("simpleTest.html")31screenshot = driver.execute("FULL_PAGE_SCREENSHOT")["value"]32result = base64.b64decode(screenshot)33kind = filetype.guess(result)34assert kind is not None and kind.mime == "image/png"353637def test_remote_webdriver_with_http_timeout(firefox_options, webserver):38"""This test starts a remote webdriver with an http client timeout39set less than the implicit wait timeout, and verifies the http timeout40is triggered first when waiting for an element.41"""42http_timeout = 643wait_timeout = 844server_addr = f"http://{webserver.host}:{webserver.port}"45client_config = ClientConfig(remote_server_addr=server_addr, timeout=http_timeout)46assert client_config.timeout == http_timeout47with webdriver.Remote(options=firefox_options, client_config=client_config) as driver:48driver.get(f"{server_addr}/simpleTest.html")49driver.implicitly_wait(wait_timeout)50with pytest.raises(ReadTimeoutError):51driver.find_element(By.ID, "no_element_to_be_found")525354