diff --git a/py/selenium/common/__init__.py b/py/selenium/common/__init__.py index d08d6d3354226..752462cf1396d 100644 --- a/py/selenium/common/__init__.py +++ b/py/selenium/common/__init__.py @@ -49,7 +49,6 @@ from .exceptions import UnknownMethodException from .exceptions import WebDriverException - __all__ = ["WebDriverException", "InvalidSwitchToTargetException", "NoSuchFrameException", diff --git a/py/selenium/common/exceptions.py b/py/selenium/common/exceptions.py index ba4fee8d14b0b..96b36f7c76ee5 100644 --- a/py/selenium/common/exceptions.py +++ b/py/selenium/common/exceptions.py @@ -19,7 +19,8 @@ Exceptions that may happen in all the webdriver code. """ -from typing import Optional, Sequence +from typing import Optional +from typing import Sequence class WebDriverException(Exception): diff --git a/py/selenium/types.py b/py/selenium/types.py index 96d3830ba47ed..16cb31650e79b 100644 --- a/py/selenium/types.py +++ b/py/selenium/types.py @@ -19,6 +19,5 @@ import typing - AnyKey = typing.Union[str, int, float] WaitExcTypes = typing.Iterable[typing.Type[Exception]] diff --git a/py/selenium/webdriver/__init__.py b/py/selenium/webdriver/__init__.py index fb63dacb309a5..ecf26bc5041c3 100644 --- a/py/selenium/webdriver/__init__.py +++ b/py/selenium/webdriver/__init__.py @@ -15,26 +15,26 @@ # specific language governing permissions and limitations # under the License. -from .firefox.webdriver import WebDriver as Firefox # noqa +from .chrome.options import Options as ChromeOptions # noqa +from .chrome.webdriver import WebDriver as Chrome # noqa +from .common.action_chains import ActionChains # noqa +from .common.desired_capabilities import DesiredCapabilities # noqa +from .common.keys import Keys # noqa +from .common.proxy import Proxy # noqa +from .edge.options import Options as EdgeOptions # noqa +from .edge.webdriver import WebDriver as ChromiumEdge # noqa +from .edge.webdriver import WebDriver as Edge # noqa from .firefox.firefox_profile import FirefoxProfile # noqa from .firefox.options import Options as FirefoxOptions # noqa -from .chrome.webdriver import WebDriver as Chrome # noqa -from .chrome.options import Options as ChromeOptions # noqa -from .ie.webdriver import WebDriver as Ie # noqa +from .firefox.webdriver import WebDriver as Firefox # noqa from .ie.options import Options as IeOptions # noqa -from .edge.webdriver import WebDriver as Edge # noqa -from .edge.webdriver import WebDriver as ChromiumEdge # noqa -from .edge.options import Options as EdgeOptions # noqa +from .ie.webdriver import WebDriver as Ie # noqa +from .remote.webdriver import WebDriver as Remote # noqa from .safari.webdriver import WebDriver as Safari # noqa -from .webkitgtk.webdriver import WebDriver as WebKitGTK # noqa from .webkitgtk.options import Options as WebKitGTKOptions # noqa -from .wpewebkit.webdriver import WebDriver as WPEWebKit # noqa +from .webkitgtk.webdriver import WebDriver as WebKitGTK # noqa from .wpewebkit.options import Options as WPEWebKitOptions # noqa -from .remote.webdriver import WebDriver as Remote # noqa -from .common.desired_capabilities import DesiredCapabilities # noqa -from .common.action_chains import ActionChains # noqa -from .common.proxy import Proxy # noqa -from .common.keys import Keys # noqa +from .wpewebkit.webdriver import WebDriver as WPEWebKit # noqa __version__ = '4.5.0' diff --git a/py/selenium/webdriver/chrome/options.py b/py/selenium/webdriver/chrome/options.py index 80ef3064c6e84..cc12a955403b9 100644 --- a/py/selenium/webdriver/chrome/options.py +++ b/py/selenium/webdriver/chrome/options.py @@ -15,9 +15,10 @@ # specific language governing permissions and limitations # under the License. +from typing import Optional + from selenium.webdriver.chromium.options import ChromiumOptions from selenium.webdriver.common.desired_capabilities import DesiredCapabilities -from typing import Optional class Options(ChromiumOptions): diff --git a/py/selenium/webdriver/chrome/service.py b/py/selenium/webdriver/chrome/service.py index d12085cfedadf..552f7d49d5c6d 100644 --- a/py/selenium/webdriver/chrome/service.py +++ b/py/selenium/webdriver/chrome/service.py @@ -16,8 +16,8 @@ # under the License. from typing import List -from selenium.webdriver.chromium import service +from selenium.webdriver.chromium import service DEFAULT_EXECUTABLE_PATH = "chromedriver" diff --git a/py/selenium/webdriver/chrome/webdriver.py b/py/selenium/webdriver/chrome/webdriver.py index 02fc1cd62cb09..2dc6dba06f384 100644 --- a/py/selenium/webdriver/chrome/webdriver.py +++ b/py/selenium/webdriver/chrome/webdriver.py @@ -15,11 +15,14 @@ # specific language governing permissions and limitations # under the License. import warnings + from selenium.webdriver.chromium.webdriver import ChromiumDriver -from .options import Options -from .service import DEFAULT_EXECUTABLE_PATH, Service from selenium.webdriver.common.desired_capabilities import DesiredCapabilities +from .options import Options +from .service import DEFAULT_EXECUTABLE_PATH +from .service import Service + DEFAULT_PORT = 0 DEFAULT_SERVICE_LOG_PATH = None DEFAULT_KEEP_ALIVE = None diff --git a/py/selenium/webdriver/chromium/options.py b/py/selenium/webdriver/chromium/options.py index f33f5b14b469a..c100b4c539548 100644 --- a/py/selenium/webdriver/chromium/options.py +++ b/py/selenium/webdriver/chromium/options.py @@ -18,7 +18,9 @@ import base64 import os import warnings -from typing import List, Union, BinaryIO +from typing import BinaryIO +from typing import List +from typing import Union from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.common.options import ArgOptions diff --git a/py/selenium/webdriver/chromium/service.py b/py/selenium/webdriver/chromium/service.py index c270bedf4b796..ffd0165514f84 100644 --- a/py/selenium/webdriver/chromium/service.py +++ b/py/selenium/webdriver/chromium/service.py @@ -16,6 +16,7 @@ # under the License. from typing import List + from selenium.webdriver.common import service diff --git a/py/selenium/webdriver/chromium/webdriver.py b/py/selenium/webdriver/chromium/webdriver.py index 5bedfbc914d8c..233e277bfa175 100644 --- a/py/selenium/webdriver/chromium/webdriver.py +++ b/py/selenium/webdriver/chromium/webdriver.py @@ -15,13 +15,13 @@ # specific language governing permissions and limitations # under the License. -from selenium.webdriver.common.options import BaseOptions -from selenium.webdriver.common.service import Service -from selenium.webdriver.edge.options import Options as EdgeOptions -from selenium.webdriver.chrome.options import Options as ChromeOptions import warnings +from selenium.webdriver.chrome.options import Options as ChromeOptions from selenium.webdriver.chromium.remote_connection import ChromiumRemoteConnection +from selenium.webdriver.common.options import BaseOptions +from selenium.webdriver.common.service import Service +from selenium.webdriver.edge.options import Options as EdgeOptions from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver DEFAULT_PORT = 0 diff --git a/py/selenium/webdriver/common/action_chains.py b/py/selenium/webdriver/common/action_chains.py index bb1240b838830..d0f1903650ef1 100644 --- a/py/selenium/webdriver/common/action_chains.py +++ b/py/selenium/webdriver/common/action_chains.py @@ -20,11 +20,11 @@ """ import warnings -from .actions.wheel_input import ScrollOrigin +from selenium.webdriver.remote.webelement import WebElement -from .utils import keys_to_typing from .actions.action_builder import ActionBuilder -from selenium.webdriver.remote.webelement import WebElement +from .actions.wheel_input import ScrollOrigin +from .utils import keys_to_typing class ActionChains: diff --git a/py/selenium/webdriver/common/actions/action_builder.py b/py/selenium/webdriver/common/actions/action_builder.py index f5d1c16314406..34c54c9782f4a 100644 --- a/py/selenium/webdriver/common/actions/action_builder.py +++ b/py/selenium/webdriver/common/actions/action_builder.py @@ -15,15 +15,18 @@ # specific language governing permissions and limitations # under the License. -from typing import Union, List +from typing import List +from typing import Union + from selenium.webdriver.remote.command import Command + from . import interaction from .key_actions import KeyActions from .key_input import KeyInput from .pointer_actions import PointerActions from .pointer_input import PointerInput -from .wheel_input import WheelInput from .wheel_actions import WheelActions +from .wheel_input import WheelInput class ActionBuilder: diff --git a/py/selenium/webdriver/common/actions/key_actions.py b/py/selenium/webdriver/common/actions/key_actions.py index 3c7546ab62f06..1ec66d0f98d64 100644 --- a/py/selenium/webdriver/common/actions/key_actions.py +++ b/py/selenium/webdriver/common/actions/key_actions.py @@ -14,9 +14,10 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -from .interaction import Interaction, KEY -from .key_input import KeyInput from ..utils import keys_to_typing +from .interaction import KEY +from .interaction import Interaction +from .key_input import KeyInput class KeyActions(Interaction): diff --git a/py/selenium/webdriver/common/actions/key_input.py b/py/selenium/webdriver/common/actions/key_input.py index a27506c7f04f1..dfd0dcd4d3f31 100644 --- a/py/selenium/webdriver/common/actions/key_input.py +++ b/py/selenium/webdriver/common/actions/key_input.py @@ -15,10 +15,9 @@ # specific language governing permissions and limitations # under the License. from . import interaction - from .input_device import InputDevice -from .interaction import (Interaction, - Pause) +from .interaction import Interaction +from .interaction import Pause class KeyInput(InputDevice): diff --git a/py/selenium/webdriver/common/actions/pointer_actions.py b/py/selenium/webdriver/common/actions/pointer_actions.py index f6212a0fc1a59..daac5ee92f7ca 100644 --- a/py/selenium/webdriver/common/actions/pointer_actions.py +++ b/py/selenium/webdriver/common/actions/pointer_actions.py @@ -16,6 +16,7 @@ # under the License. from selenium.webdriver.remote.webelement import WebElement + from . import interaction from .interaction import Interaction from .mouse_button import MouseButton diff --git a/py/selenium/webdriver/common/actions/pointer_input.py b/py/selenium/webdriver/common/actions/pointer_input.py index b3763aaa07687..75983bf234116 100644 --- a/py/selenium/webdriver/common/actions/pointer_input.py +++ b/py/selenium/webdriver/common/actions/pointer_input.py @@ -18,8 +18,10 @@ from selenium.common.exceptions import InvalidArgumentException from selenium.webdriver.remote.webelement import WebElement + from .input_device import InputDevice -from .interaction import POINTER, POINTER_KINDS +from .interaction import POINTER +from .interaction import POINTER_KINDS class PointerInput(InputDevice): diff --git a/py/selenium/webdriver/common/actions/wheel_actions.py b/py/selenium/webdriver/common/actions/wheel_actions.py index 78f09703bd971..1fdbb8a85c6c0 100644 --- a/py/selenium/webdriver/common/actions/wheel_actions.py +++ b/py/selenium/webdriver/common/actions/wheel_actions.py @@ -14,8 +14,8 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -from .wheel_input import WheelInput from .interaction import Interaction +from .wheel_input import WheelInput class WheelActions(Interaction): diff --git a/py/selenium/webdriver/common/actions/wheel_input.py b/py/selenium/webdriver/common/actions/wheel_input.py index b93c853333868..2b961438e360c 100644 --- a/py/selenium/webdriver/common/actions/wheel_input.py +++ b/py/selenium/webdriver/common/actions/wheel_input.py @@ -14,12 +14,13 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -from . import interaction -from .input_device import InputDevice from typing import Union from selenium.webdriver.remote.webelement import WebElement +from . import interaction +from .input_device import InputDevice + class ScrollOrigin: diff --git a/py/selenium/webdriver/common/bidi/cdp.py b/py/selenium/webdriver/common/bidi/cdp.py index d5b9726d36e81..a45c0e1203b94 100644 --- a/py/selenium/webdriver/common/bidi/cdp.py +++ b/py/selenium/webdriver/common/bidi/cdp.py @@ -24,14 +24,6 @@ # flake8: noqa -from trio_websocket import ( - ConnectionClosed as WsConnectionClosed, - connect_websocket_url, -) -import trio -from collections import defaultdict -from contextlib import (contextmanager, asynccontextmanager) -from dataclasses import dataclass import contextvars import importlib import itertools @@ -39,7 +31,14 @@ import logging import pathlib import typing +from collections import defaultdict +from contextlib import asynccontextmanager +from contextlib import contextmanager +from dataclasses import dataclass +import trio +from trio_websocket import ConnectionClosed as WsConnectionClosed +from trio_websocket import connect_websocket_url logger = logging.getLogger('trio_cdp') T = typing.TypeVar('T') diff --git a/py/selenium/webdriver/common/log.py b/py/selenium/webdriver/common/log.py index 24f460ed6c067..5c6bcb3a32251 100644 --- a/py/selenium/webdriver/common/log.py +++ b/py/selenium/webdriver/common/log.py @@ -17,7 +17,6 @@ import json import pkgutil - from contextlib import asynccontextmanager from importlib import import_module diff --git a/py/selenium/webdriver/common/options.py b/py/selenium/webdriver/common/options.py index 783a2c6ced886..ac36d74c0e0f6 100644 --- a/py/selenium/webdriver/common/options.py +++ b/py/selenium/webdriver/common/options.py @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. import typing -from abc import ABCMeta, abstractmethod +from abc import ABCMeta +from abc import abstractmethod from selenium.common.exceptions import InvalidArgumentException from selenium.webdriver.common.proxy import Proxy diff --git a/py/selenium/webdriver/common/print_page_options.py b/py/selenium/webdriver/common/print_page_options.py index 433f388275fa2..539c50b53394c 100644 --- a/py/selenium/webdriver/common/print_page_options.py +++ b/py/selenium/webdriver/common/print_page_options.py @@ -17,14 +17,18 @@ import sys -from typing import TYPE_CHECKING, List, Optional +from typing import TYPE_CHECKING +from typing import List +from typing import Optional # necessary to support types for Python 3.7 if TYPE_CHECKING: if sys.version_info >= (3, 8): - from typing import Literal, TypedDict + from typing import Literal + from typing import TypedDict else: - from typing_extensions import Literal, TypedDict + from typing_extensions import Literal + from typing_extensions import TypedDict Orientation = Literal['portrait', 'landscape'] @@ -47,7 +51,8 @@ class _PrintOpts(TypedDict, total=False): shrinkToFit: bool pageRanges: List[str] else: - from typing import Any, Dict + from typing import Any + from typing import Dict Orientation = str _MarginOpts = _PageOpts = _PrintOpts = Dict[str, Any] diff --git a/py/selenium/webdriver/common/service.py b/py/selenium/webdriver/common/service.py index 3c5d79b9ee25d..c5a6f8f4cf874 100644 --- a/py/selenium/webdriver/common/service.py +++ b/py/selenium/webdriver/common/service.py @@ -14,18 +14,17 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -from subprocess import DEVNULL - import errno import os import subprocess from platform import system +from subprocess import DEVNULL from subprocess import PIPE from time import sleep + from selenium.common.exceptions import WebDriverException from selenium.webdriver.common import utils - _HAS_NATIVE_DEVNULL = True diff --git a/py/selenium/webdriver/common/timeouts.py b/py/selenium/webdriver/common/timeouts.py index 68ec5649e1e28..72dc0a71a2330 100644 --- a/py/selenium/webdriver/common/timeouts.py +++ b/py/selenium/webdriver/common/timeouts.py @@ -18,7 +18,6 @@ from typing import TYPE_CHECKING - if TYPE_CHECKING: import sys if sys.version_info >= (3, 8): diff --git a/py/selenium/webdriver/common/utils.py b/py/selenium/webdriver/common/utils.py index b5b99c29d5d22..f76f7019cc188 100644 --- a/py/selenium/webdriver/common/utils.py +++ b/py/selenium/webdriver/common/utils.py @@ -19,13 +19,15 @@ The Utils methods. """ -from typing import Iterable, List, Optional, Union - import socket +from typing import Iterable +from typing import List +from typing import Optional +from typing import Union + from selenium.types import AnyKey from selenium.webdriver.common.keys import Keys - _is_connectable_exceptions = (socket.error, ConnectionResetError) diff --git a/py/selenium/webdriver/common/virtual_authenticator.py b/py/selenium/webdriver/common/virtual_authenticator.py index 6d44ceeb6a7fa..47596184f05f4 100644 --- a/py/selenium/webdriver/common/virtual_authenticator.py +++ b/py/selenium/webdriver/common/virtual_authenticator.py @@ -16,10 +16,10 @@ # under the License. import functools - -from base64 import urlsafe_b64encode, urlsafe_b64decode -from enum import Enum import typing +from base64 import urlsafe_b64decode +from base64 import urlsafe_b64encode +from enum import Enum class Protocol(Enum): diff --git a/py/selenium/webdriver/edge/options.py b/py/selenium/webdriver/edge/options.py index ca5458b1128d6..86848f2386a22 100644 --- a/py/selenium/webdriver/edge/options.py +++ b/py/selenium/webdriver/edge/options.py @@ -15,8 +15,8 @@ # specific language governing permissions and limitations # under the License. -from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.chromium.options import ChromiumOptions +from selenium.webdriver.common.desired_capabilities import DesiredCapabilities class Options(ChromiumOptions): diff --git a/py/selenium/webdriver/edge/service.py b/py/selenium/webdriver/edge/service.py index 8d9d1088958d9..f70c8b1b7e301 100644 --- a/py/selenium/webdriver/edge/service.py +++ b/py/selenium/webdriver/edge/service.py @@ -16,8 +16,8 @@ # under the License. from typing import List -from selenium.webdriver.chromium import service +from selenium.webdriver.chromium import service DEFAULT_EXECUTABLE_PATH = 'msedgedriver' diff --git a/py/selenium/webdriver/edge/webdriver.py b/py/selenium/webdriver/edge/webdriver.py index 112f3cb1060b7..1d5a234c37428 100644 --- a/py/selenium/webdriver/edge/webdriver.py +++ b/py/selenium/webdriver/edge/webdriver.py @@ -15,11 +15,14 @@ # specific language governing permissions and limitations # under the License. import warnings + from selenium.webdriver.chromium.webdriver import ChromiumDriver -from .options import Options -from .service import DEFAULT_EXECUTABLE_PATH, Service from selenium.webdriver.common.desired_capabilities import DesiredCapabilities +from .options import Options +from .service import DEFAULT_EXECUTABLE_PATH +from .service import Service + DEFAULT_PORT = 0 DEFAULT_SERVICE_LOG_PATH = None diff --git a/py/selenium/webdriver/firefox/extension_connection.py b/py/selenium/webdriver/firefox/extension_connection.py index c6d7d914b89de..1c72fb6d918f1 100644 --- a/py/selenium/webdriver/firefox/extension_connection.py +++ b/py/selenium/webdriver/firefox/extension_connection.py @@ -18,11 +18,11 @@ import logging import time -from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.common import utils +from selenium.webdriver.common.desired_capabilities import DesiredCapabilities +from selenium.webdriver.firefox.firefox_binary import FirefoxBinary from selenium.webdriver.remote.command import Command from selenium.webdriver.remote.remote_connection import RemoteConnection -from selenium.webdriver.firefox.firefox_binary import FirefoxBinary LOGGER = logging.getLogger(__name__) PORT = 0 diff --git a/py/selenium/webdriver/firefox/firefox_binary.py b/py/selenium/webdriver/firefox/firefox_binary.py index ff66f8325334d..b1a04326d60d0 100644 --- a/py/selenium/webdriver/firefox/firefox_binary.py +++ b/py/selenium/webdriver/firefox/firefox_binary.py @@ -17,11 +17,13 @@ import os +import time from platform import system -from subprocess import Popen, STDOUT +from subprocess import STDOUT +from subprocess import Popen + from selenium.common.exceptions import WebDriverException from selenium.webdriver.common import utils -import time class FirefoxBinary: @@ -119,7 +121,10 @@ def _wait_until_connectable(self, timeout=30): def _find_exe_in_registry(self): try: - from _winreg import OpenKey, QueryValue, HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER + from _winreg import HKEY_CURRENT_USER + from _winreg import HKEY_LOCAL_MACHINE + from _winreg import OpenKey + from _winreg import QueryValue except ImportError: from winreg import OpenKey, QueryValue, HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER import shlex diff --git a/py/selenium/webdriver/firefox/firefox_profile.py b/py/selenium/webdriver/firefox/firefox_profile.py index e0cf29af46e06..3e83400cef831 100644 --- a/py/selenium/webdriver/firefox/firefox_profile.py +++ b/py/selenium/webdriver/firefox/firefox_profile.py @@ -30,7 +30,6 @@ from selenium.common.exceptions import WebDriverException - WEBDRIVER_EXT = "webdriver.xpi" WEBDRIVER_PREFERENCES = "webdriver_prefs.json" EXTENSION_NAME = "fxdriver@googlecode.com" diff --git a/py/selenium/webdriver/firefox/options.py b/py/selenium/webdriver/firefox/options.py index db5c21878c625..d600c0d9daf52 100644 --- a/py/selenium/webdriver/firefox/options.py +++ b/py/selenium/webdriver/firefox/options.py @@ -14,12 +14,13 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -from typing import Union import warnings +from typing import Union + from selenium.webdriver.common.desired_capabilities import DesiredCapabilities +from selenium.webdriver.common.options import ArgOptions from selenium.webdriver.firefox.firefox_binary import FirefoxBinary from selenium.webdriver.firefox.firefox_profile import FirefoxProfile -from selenium.webdriver.common.options import ArgOptions class Log: diff --git a/py/selenium/webdriver/firefox/remote_connection.py b/py/selenium/webdriver/firefox/remote_connection.py index eb359d5eb4746..927b80a4fa02e 100644 --- a/py/selenium/webdriver/firefox/remote_connection.py +++ b/py/selenium/webdriver/firefox/remote_connection.py @@ -15,8 +15,8 @@ # specific language governing permissions and limitations # under the License. -from selenium.webdriver.remote.remote_connection import RemoteConnection from selenium.webdriver.common.desired_capabilities import DesiredCapabilities +from selenium.webdriver.remote.remote_connection import RemoteConnection class FirefoxRemoteConnection(RemoteConnection): diff --git a/py/selenium/webdriver/firefox/service.py b/py/selenium/webdriver/firefox/service.py index 3ce21f88a7f74..85e9c4914df7d 100644 --- a/py/selenium/webdriver/firefox/service.py +++ b/py/selenium/webdriver/firefox/service.py @@ -17,7 +17,8 @@ from typing import List -from selenium.webdriver.common import (service, utils) +from selenium.webdriver.common import service +from selenium.webdriver.common import utils DEFAULT_EXECUTABLE_PATH = "geckodriver" diff --git a/py/selenium/webdriver/firefox/webdriver.py b/py/selenium/webdriver/firefox/webdriver.py index b8c70e27ff8aa..5f3ffae703c6b 100644 --- a/py/selenium/webdriver/firefox/webdriver.py +++ b/py/selenium/webdriver/firefox/webdriver.py @@ -15,12 +15,12 @@ # specific language governing permissions and limitations # under the License. import base64 -from io import BytesIO import os -from shutil import rmtree import warnings -from contextlib import contextmanager import zipfile +from contextlib import contextmanager +from io import BytesIO +from shutil import rmtree from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver @@ -29,8 +29,8 @@ from .firefox_profile import FirefoxProfile from .options import Options from .remote_connection import FirefoxRemoteConnection -from .service import DEFAULT_EXECUTABLE_PATH, Service - +from .service import DEFAULT_EXECUTABLE_PATH +from .service import Service # Default for log_path variable. To be deleted when deprecations for arguments are removed. DEFAULT_LOG_PATH = None diff --git a/py/selenium/webdriver/ie/webdriver.py b/py/selenium/webdriver/ie/webdriver.py index 0cb659b3ab11b..576f51b57e060 100644 --- a/py/selenium/webdriver/ie/webdriver.py +++ b/py/selenium/webdriver/ie/webdriver.py @@ -17,10 +17,12 @@ import warnings +from selenium.webdriver.common import utils from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver -from .service import DEFAULT_EXECUTABLE_PATH, Service + from .options import Options -from selenium.webdriver.common import utils +from .service import DEFAULT_EXECUTABLE_PATH +from .service import Service DEFAULT_TIMEOUT = 30 DEFAULT_PORT = 0 diff --git a/py/selenium/webdriver/remote/errorhandler.py b/py/selenium/webdriver/remote/errorhandler.py index 676b99afab53d..8988c9e5a7f89 100644 --- a/py/selenium/webdriver/remote/errorhandler.py +++ b/py/selenium/webdriver/remote/errorhandler.py @@ -15,37 +15,39 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, Dict, Type +from typing import Any +from typing import Dict +from typing import Type -from selenium.common.exceptions import (ElementClickInterceptedException, - ElementNotInteractableException, - ElementNotSelectableException, - ElementNotVisibleException, - InsecureCertificateException, - InvalidCoordinatesException, - InvalidElementStateException, - InvalidSessionIdException, - InvalidSelectorException, - ImeNotAvailableException, - ImeActivationFailedException, - InvalidArgumentException, - InvalidCookieDomainException, - JavascriptException, - MoveTargetOutOfBoundsException, - NoSuchCookieException, - NoSuchElementException, - NoSuchFrameException, - NoSuchShadowRootException, - NoSuchWindowException, - NoAlertPresentException, - ScreenshotException, - SessionNotCreatedException, - StaleElementReferenceException, - TimeoutException, - UnableToSetCookieException, - UnexpectedAlertPresentException, - UnknownMethodException, - WebDriverException) +from selenium.common.exceptions import ElementClickInterceptedException +from selenium.common.exceptions import ElementNotInteractableException +from selenium.common.exceptions import ElementNotSelectableException +from selenium.common.exceptions import ElementNotVisibleException +from selenium.common.exceptions import ImeActivationFailedException +from selenium.common.exceptions import ImeNotAvailableException +from selenium.common.exceptions import InsecureCertificateException +from selenium.common.exceptions import InvalidArgumentException +from selenium.common.exceptions import InvalidCookieDomainException +from selenium.common.exceptions import InvalidCoordinatesException +from selenium.common.exceptions import InvalidElementStateException +from selenium.common.exceptions import InvalidSelectorException +from selenium.common.exceptions import InvalidSessionIdException +from selenium.common.exceptions import JavascriptException +from selenium.common.exceptions import MoveTargetOutOfBoundsException +from selenium.common.exceptions import NoAlertPresentException +from selenium.common.exceptions import NoSuchCookieException +from selenium.common.exceptions import NoSuchElementException +from selenium.common.exceptions import NoSuchFrameException +from selenium.common.exceptions import NoSuchShadowRootException +from selenium.common.exceptions import NoSuchWindowException +from selenium.common.exceptions import ScreenshotException +from selenium.common.exceptions import SessionNotCreatedException +from selenium.common.exceptions import StaleElementReferenceException +from selenium.common.exceptions import TimeoutException +from selenium.common.exceptions import UnableToSetCookieException +from selenium.common.exceptions import UnexpectedAlertPresentException +from selenium.common.exceptions import UnknownMethodException +from selenium.common.exceptions import WebDriverException class ErrorCode: diff --git a/py/selenium/webdriver/remote/file_detector.py b/py/selenium/webdriver/remote/file_detector.py index a0e15f2bdb76a..43eb3c4488186 100644 --- a/py/selenium/webdriver/remote/file_detector.py +++ b/py/selenium/webdriver/remote/file_detector.py @@ -15,9 +15,11 @@ # specific language governing permissions and limitations # under the License. -from abc import ABCMeta, abstractmethod import os +from abc import ABCMeta +from abc import abstractmethod from typing import Optional + from selenium.types import AnyKey from selenium.webdriver.common.utils import keys_to_typing diff --git a/py/selenium/webdriver/remote/remote_connection.py b/py/selenium/webdriver/remote/remote_connection.py index 5ca59e1fc4626..85cf633b33384 100644 --- a/py/selenium/webdriver/remote/remote_connection.py +++ b/py/selenium/webdriver/remote/remote_connection.py @@ -16,23 +16,22 @@ # under the License. import logging +import os +import platform import socket import string - -import os import typing +from base64 import b64encode +from urllib import parse import certifi import urllib3 -import platform -from base64 import b64encode - -from urllib import parse from selenium import __version__ + +from . import utils from .command import Command from .errorhandler import ErrorCode -from . import utils LOGGER = logging.getLogger(__name__) diff --git a/py/selenium/webdriver/remote/shadowroot.py b/py/selenium/webdriver/remote/shadowroot.py index 72db4d2940c88..4c9e6e28ef0b4 100644 --- a/py/selenium/webdriver/remote/shadowroot.py +++ b/py/selenium/webdriver/remote/shadowroot.py @@ -17,8 +17,8 @@ from hashlib import md5 as md5_hash -from .command import Command from ..common.by import By +from .command import Command class ShadowRoot: diff --git a/py/selenium/webdriver/remote/switch_to.py b/py/selenium/webdriver/remote/switch_to.py index 6f78d90c4e3fd..29890a1e767b2 100644 --- a/py/selenium/webdriver/remote/switch_to.py +++ b/py/selenium/webdriver/remote/switch_to.py @@ -15,15 +15,15 @@ # specific language governing permissions and limitations # under the License. -from .command import Command - -from selenium.common.exceptions import (NoSuchElementException, - NoSuchFrameException, - NoSuchWindowException) +from selenium.common.exceptions import NoSuchElementException +from selenium.common.exceptions import NoSuchFrameException +from selenium.common.exceptions import NoSuchWindowException from selenium.webdriver.common.alert import Alert from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement +from .command import Command + class SwitchTo: def __init__(self, driver): diff --git a/py/selenium/webdriver/remote/utils.py b/py/selenium/webdriver/remote/utils.py index 8e440e0e1246e..ec849b2ea2fd5 100644 --- a/py/selenium/webdriver/remote/utils.py +++ b/py/selenium/webdriver/remote/utils.py @@ -16,7 +16,8 @@ # under the License. import json -from typing import Any, Union +from typing import Any +from typing import Union def dump_json(json_struct: Any) -> str: diff --git a/py/selenium/webdriver/remote/webdriver.py b/py/selenium/webdriver/remote/webdriver.py index 8f60942bf92bb..fd5545573ec56 100644 --- a/py/selenium/webdriver/remote/webdriver.py +++ b/py/selenium/webdriver/remote/webdriver.py @@ -23,31 +23,38 @@ import typing import warnings from abc import ABCMeta -from base64 import b64decode, urlsafe_b64encode -from contextlib import asynccontextmanager, contextmanager +from base64 import b64decode +from base64 import urlsafe_b64encode +from contextlib import asynccontextmanager +from contextlib import contextmanager from importlib import import_module -from typing import Dict, List, Optional, Union - -from selenium.common.exceptions import (InvalidArgumentException, - JavascriptException, - WebDriverException, - NoSuchCookieException, - NoSuchElementException) +from typing import Dict +from typing import List +from typing import Optional +from typing import Union + +from selenium.common.exceptions import InvalidArgumentException +from selenium.common.exceptions import JavascriptException +from selenium.common.exceptions import NoSuchCookieException +from selenium.common.exceptions import NoSuchElementException +from selenium.common.exceptions import WebDriverException from selenium.webdriver.common.by import By from selenium.webdriver.common.html5.application_cache import ApplicationCache from selenium.webdriver.common.options import BaseOptions from selenium.webdriver.common.print_page_options import PrintOptions from selenium.webdriver.common.timeouts import Timeouts +from selenium.webdriver.common.virtual_authenticator import Credential +from selenium.webdriver.common.virtual_authenticator import VirtualAuthenticatorOptions from selenium.webdriver.common.virtual_authenticator import ( - Credential, - VirtualAuthenticatorOptions, - required_virtual_authenticator + required_virtual_authenticator, ) from selenium.webdriver.support.relative_locator import RelativeBy + from .bidi_connection import BidiConnection from .command import Command from .errorhandler import ErrorHandler -from .file_detector import FileDetector, LocalFileDetector +from .file_detector import FileDetector +from .file_detector import LocalFileDetector from .mobile import Mobile from .remote_connection import RemoteConnection from .script_key import ScriptKey @@ -123,8 +130,8 @@ def _make_w3c_caps(caps): def get_remote_connection(capabilities, command_executor, keep_alive, ignore_local_proxy=False): from selenium.webdriver.chromium.remote_connection import ChromiumRemoteConnection - from selenium.webdriver.safari.remote_connection import SafariRemoteConnection from selenium.webdriver.firefox.remote_connection import FirefoxRemoteConnection + from selenium.webdriver.safari.remote_connection import SafariRemoteConnection candidates = [RemoteConnection, ChromiumRemoteConnection, SafariRemoteConnection, FirefoxRemoteConnection] handler = next( @@ -1187,6 +1194,7 @@ async def bidi_connection(self): def _get_cdp_details(self): import json + import urllib3 http = urllib3.PoolManager() diff --git a/py/selenium/webdriver/remote/webelement.py b/py/selenium/webdriver/remote/webelement.py index 222792f10e7fd..d486651b787b0 100644 --- a/py/selenium/webdriver/remote/webelement.py +++ b/py/selenium/webdriver/remote/webelement.py @@ -17,17 +17,20 @@ from __future__ import annotations import os -from base64 import b64decode, encodebytes -from hashlib import md5 as md5_hash import pkgutil import warnings import zipfile from abc import ABCMeta +from base64 import b64decode +from base64 import encodebytes +from hashlib import md5 as md5_hash from io import BytesIO -from selenium.common.exceptions import WebDriverException, JavascriptException +from selenium.common.exceptions import JavascriptException +from selenium.common.exceptions import WebDriverException from selenium.webdriver.common.by import By from selenium.webdriver.common.utils import keys_to_typing + from .command import Command from .shadowroot import ShadowRoot diff --git a/py/selenium/webdriver/safari/remote_connection.py b/py/selenium/webdriver/safari/remote_connection.py index 40a90bd141f1f..cd2139b4a941a 100644 --- a/py/selenium/webdriver/safari/remote_connection.py +++ b/py/selenium/webdriver/safari/remote_connection.py @@ -15,8 +15,8 @@ # specific language governing permissions and limitations # under the License. -from selenium.webdriver.remote.remote_connection import RemoteConnection from selenium.webdriver.common.desired_capabilities import DesiredCapabilities +from selenium.webdriver.remote.remote_connection import RemoteConnection class SafariRemoteConnection(RemoteConnection): diff --git a/py/selenium/webdriver/safari/service.py b/py/selenium/webdriver/safari/service.py index c6ec7ff58060c..e24e1c5cd15d0 100644 --- a/py/selenium/webdriver/safari/service.py +++ b/py/selenium/webdriver/safari/service.py @@ -16,9 +16,10 @@ # under the License. import os -from selenium.webdriver.common import service, utils from subprocess import PIPE +from selenium.webdriver.common import service +from selenium.webdriver.common import utils DEFAULT_EXECUTABLE_PATH = "/usr/bin/safaridriver" diff --git a/py/selenium/webdriver/safari/webdriver.py b/py/selenium/webdriver/safari/webdriver.py index c6177605f825e..d035380e128c1 100644 --- a/py/selenium/webdriver/safari/webdriver.py +++ b/py/selenium/webdriver/safari/webdriver.py @@ -16,17 +16,16 @@ # under the License. import http.client as http_client - - import warnings from selenium.common.exceptions import WebDriverException from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver + from .options import Options -from .service import DEFAULT_EXECUTABLE_PATH, Service from .remote_connection import SafariRemoteConnection - +from .service import DEFAULT_EXECUTABLE_PATH +from .service import Service DEFAULT_SAFARI_CAPS = DesiredCapabilities.SAFARI.copy() diff --git a/py/selenium/webdriver/support/color.py b/py/selenium/webdriver/support/color.py index bbf1d964277f2..5152f8be2cdbe 100644 --- a/py/selenium/webdriver/support/color.py +++ b/py/selenium/webdriver/support/color.py @@ -17,7 +17,9 @@ from __future__ import annotations import sys -from typing import Any, Sequence, TYPE_CHECKING +from typing import TYPE_CHECKING +from typing import Any +from typing import Sequence if sys.version_info >= (3, 9): from re import Match @@ -25,7 +27,10 @@ from typing import Match if TYPE_CHECKING: - from typing import SupportsInt, SupportsFloat, Union + from typing import SupportsFloat + from typing import SupportsInt + from typing import Union + from typing_extensions import SupportsIndex ParseableFloat = Union[SupportsFloat, SupportsIndex, str, bytes, bytearray] diff --git a/py/selenium/webdriver/support/event_firing_webdriver.py b/py/selenium/webdriver/support/event_firing_webdriver.py index c2938d0163637..0dbd227a377e4 100644 --- a/py/selenium/webdriver/support/event_firing_webdriver.py +++ b/py/selenium/webdriver/support/event_firing_webdriver.py @@ -20,6 +20,7 @@ from selenium.webdriver.common.by import By from selenium.webdriver.remote.webdriver import WebDriver from selenium.webdriver.remote.webelement import WebElement + from .abstract_event_listener import AbstractEventListener diff --git a/py/selenium/webdriver/support/expected_conditions.py b/py/selenium/webdriver/support/expected_conditions.py index f474bd39700dc..55a58b817f511 100644 --- a/py/selenium/webdriver/support/expected_conditions.py +++ b/py/selenium/webdriver/support/expected_conditions.py @@ -17,11 +17,11 @@ import re +from selenium.common.exceptions import NoAlertPresentException from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoSuchFrameException from selenium.common.exceptions import StaleElementReferenceException from selenium.common.exceptions import WebDriverException -from selenium.common.exceptions import NoAlertPresentException from selenium.webdriver.remote.webdriver import WebElement """ diff --git a/py/selenium/webdriver/support/relative_locator.py b/py/selenium/webdriver/support/relative_locator.py index 8363e5d0f79ff..a421531f08fd4 100644 --- a/py/selenium/webdriver/support/relative_locator.py +++ b/py/selenium/webdriver/support/relative_locator.py @@ -16,7 +16,10 @@ # under the License. -from typing import Dict, List, Union +from typing import Dict +from typing import List +from typing import Union + from selenium.common.exceptions import WebDriverException from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement diff --git a/py/selenium/webdriver/support/select.py b/py/selenium/webdriver/support/select.py index b9e4c9f048d08..8c62dca927f97 100644 --- a/py/selenium/webdriver/support/select.py +++ b/py/selenium/webdriver/support/select.py @@ -15,8 +15,9 @@ # specific language governing permissions and limitations # under the License. +from selenium.common.exceptions import NoSuchElementException +from selenium.common.exceptions import UnexpectedTagNameException from selenium.webdriver.common.by import By -from selenium.common.exceptions import NoSuchElementException, UnexpectedTagNameException class Select: diff --git a/py/selenium/webdriver/support/wait.py b/py/selenium/webdriver/support/wait.py index 4952d4c8575c8..c6ee8ca85c1bd 100644 --- a/py/selenium/webdriver/support/wait.py +++ b/py/selenium/webdriver/support/wait.py @@ -18,9 +18,9 @@ import time import typing -from selenium.types import WaitExcTypes from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import TimeoutException +from selenium.types import WaitExcTypes POLL_FREQUENCY: float = 0.5 # How long to sleep in between calls to the method IGNORED_EXCEPTIONS: typing.Tuple[typing.Type[Exception]] = (NoSuchElementException,) # default to be ignored. diff --git a/py/selenium/webdriver/webkitgtk/service.py b/py/selenium/webdriver/webkitgtk/service.py index 770b7b5c51b6c..caae223ee991f 100644 --- a/py/selenium/webdriver/webkitgtk/service.py +++ b/py/selenium/webdriver/webkitgtk/service.py @@ -17,7 +17,6 @@ from selenium.webdriver.common import service - DEFAULT_EXECUTABLE_PATH = "WebKitWebDriver" diff --git a/py/selenium/webdriver/webkitgtk/webdriver.py b/py/selenium/webdriver/webkitgtk/webdriver.py index ee775f21297c5..ff25d2bdae564 100644 --- a/py/selenium/webdriver/webkitgtk/webdriver.py +++ b/py/selenium/webdriver/webkitgtk/webdriver.py @@ -17,10 +17,11 @@ import http.client as http_client - from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver -from .service import DEFAULT_EXECUTABLE_PATH, Service + from .options import Options +from .service import DEFAULT_EXECUTABLE_PATH +from .service import Service class WebDriver(RemoteWebDriver): diff --git a/py/selenium/webdriver/wpewebkit/service.py b/py/selenium/webdriver/wpewebkit/service.py index b8fbd684eb2ce..85781b12bd582 100644 --- a/py/selenium/webdriver/wpewebkit/service.py +++ b/py/selenium/webdriver/wpewebkit/service.py @@ -17,7 +17,6 @@ from selenium.webdriver.common import service - DEFAULT_EXECUTABLE_PATH = "WPEWebDriver" diff --git a/py/selenium/webdriver/wpewebkit/webdriver.py b/py/selenium/webdriver/wpewebkit/webdriver.py index 6bc6b0832a08b..1c0322409c4c0 100644 --- a/py/selenium/webdriver/wpewebkit/webdriver.py +++ b/py/selenium/webdriver/wpewebkit/webdriver.py @@ -17,10 +17,11 @@ import http.client as http_client - from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver -from .service import DEFAULT_EXECUTABLE_PATH, Service + +from .service import DEFAULT_EXECUTABLE_PATH +from .service import Service class WebDriver(RemoteWebDriver): diff --git a/py/test/selenium/webdriver/chrome/proxy_tests.py b/py/test/selenium/webdriver/chrome/proxy_tests.py index 49cec9c5124fb..f29684396e6ba 100644 --- a/py/test/selenium/webdriver/chrome/proxy_tests.py +++ b/py/test/selenium/webdriver/chrome/proxy_tests.py @@ -16,6 +16,7 @@ # under the License. import os + import urllib3 from selenium import webdriver diff --git a/py/test/selenium/webdriver/common/alerts_tests.py b/py/test/selenium/webdriver/common/alerts_tests.py index 6bc191488ca36..876e74421d1bc 100644 --- a/py/test/selenium/webdriver/common/alerts_tests.py +++ b/py/test/selenium/webdriver/common/alerts_tests.py @@ -19,13 +19,12 @@ import pytest +from selenium.common.exceptions import InvalidElementStateException +from selenium.common.exceptions import NoAlertPresentException +from selenium.common.exceptions import UnexpectedAlertPresentException from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.wait import WebDriverWait -from selenium.common.exceptions import ( - InvalidElementStateException, - NoAlertPresentException, - UnexpectedAlertPresentException) @pytest.fixture(autouse=True) diff --git a/py/test/selenium/webdriver/common/api_example_tests.py b/py/test/selenium/webdriver/common/api_example_tests.py index adb962f591925..48ebe27ce1514 100644 --- a/py/test/selenium/webdriver/common/api_example_tests.py +++ b/py/test/selenium/webdriver/common/api_example_tests.py @@ -18,12 +18,11 @@ import pytest -from selenium.common.exceptions import ( - NoSuchElementException, - WebDriverException) +from selenium.common.exceptions import NoSuchElementException +from selenium.common.exceptions import WebDriverException from selenium.webdriver.common.by import By -from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.support.wait import WebDriverWait def test_get_title(driver, pages): diff --git a/py/test/selenium/webdriver/common/bidi_tests.py b/py/test/selenium/webdriver/common/bidi_tests.py index 6854cd5fe08f9..b44f48c11c494 100644 --- a/py/test/selenium/webdriver/common/bidi_tests.py +++ b/py/test/selenium/webdriver/common/bidi_tests.py @@ -14,14 +14,14 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +import pytest + from selenium.common.exceptions import InvalidSelectorException from selenium.webdriver.common.by import By from selenium.webdriver.common.log import Log from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait -import pytest - @pytest.mark.xfail_safari async def test_check_console_messages(driver, pages): diff --git a/py/test/selenium/webdriver/common/children_finding_tests.py b/py/test/selenium/webdriver/common/children_finding_tests.py index 6f667b2bd14e8..ec1a65b44a65d 100755 --- a/py/test/selenium/webdriver/common/children_finding_tests.py +++ b/py/test/selenium/webdriver/common/children_finding_tests.py @@ -17,9 +17,8 @@ import pytest -from selenium.common.exceptions import ( - WebDriverException, - NoSuchElementException) +from selenium.common.exceptions import NoSuchElementException +from selenium.common.exceptions import WebDriverException from selenium.webdriver.common.by import By diff --git a/py/test/selenium/webdriver/common/cookie_tests.py b/py/test/selenium/webdriver/common/cookie_tests.py index fc2ea74b8f53b..d593620b3c265 100644 --- a/py/test/selenium/webdriver/common/cookie_tests.py +++ b/py/test/selenium/webdriver/common/cookie_tests.py @@ -16,8 +16,8 @@ # under the License. import calendar -import time import random +import time import pytest diff --git a/py/test/selenium/webdriver/common/driver_element_finding_tests.py b/py/test/selenium/webdriver/common/driver_element_finding_tests.py index a94bf13d6032d..9a3efd4b5a5c4 100755 --- a/py/test/selenium/webdriver/common/driver_element_finding_tests.py +++ b/py/test/selenium/webdriver/common/driver_element_finding_tests.py @@ -17,10 +17,9 @@ import pytest +from selenium.common.exceptions import InvalidSelectorException +from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.by import By -from selenium.common.exceptions import ( - InvalidSelectorException, - NoSuchElementException) # By.id positive diff --git a/py/test/selenium/webdriver/common/element_aria_label_tests.py b/py/test/selenium/webdriver/common/element_aria_label_tests.py index 33d1fea2afd7a..86450a7494f8c 100644 --- a/py/test/selenium/webdriver/common/element_aria_label_tests.py +++ b/py/test/selenium/webdriver/common/element_aria_label_tests.py @@ -16,10 +16,10 @@ # under the License. -from selenium.webdriver.common.by import By - import pytest +from selenium.webdriver.common.by import By + @pytest.mark.xfail_firefox @pytest.mark.xfail_safari diff --git a/py/test/selenium/webdriver/common/element_aria_tests.py b/py/test/selenium/webdriver/common/element_aria_tests.py index 07b03f2f00d96..7e563ee8fdf4a 100644 --- a/py/test/selenium/webdriver/common/element_aria_tests.py +++ b/py/test/selenium/webdriver/common/element_aria_tests.py @@ -16,10 +16,10 @@ # under the License. -from selenium.webdriver.common.by import By - import pytest +from selenium.webdriver.common.by import By + @pytest.mark.xfail_firefox @pytest.mark.xfail_safari diff --git a/py/test/selenium/webdriver/common/executing_async_javascript_tests.py b/py/test/selenium/webdriver/common/executing_async_javascript_tests.py index 905f8be4f0fee..1fd669c571690 100644 --- a/py/test/selenium/webdriver/common/executing_async_javascript_tests.py +++ b/py/test/selenium/webdriver/common/executing_async_javascript_tests.py @@ -17,9 +17,9 @@ import pytest -from selenium.webdriver.common.by import By -from selenium.common.exceptions import WebDriverException from selenium.common.exceptions import TimeoutException +from selenium.common.exceptions import WebDriverException +from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement diff --git a/py/test/selenium/webdriver/common/frame_switching_tests.py b/py/test/selenium/webdriver/common/frame_switching_tests.py index 5f3fde28d6655..da482609f95e0 100644 --- a/py/test/selenium/webdriver/common/frame_switching_tests.py +++ b/py/test/selenium/webdriver/common/frame_switching_tests.py @@ -17,14 +17,12 @@ import pytest -from selenium.common.exceptions import ( - NoSuchElementException, - NoSuchFrameException, - WebDriverException) +from selenium.common.exceptions import NoSuchElementException +from selenium.common.exceptions import NoSuchFrameException +from selenium.common.exceptions import WebDriverException from selenium.webdriver.common.by import By -from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC - +from selenium.webdriver.support.ui import WebDriverWait # ---------------------------------------------------------------------------------------------- # diff --git a/py/test/selenium/webdriver/common/google_one_box.py b/py/test/selenium/webdriver/common/google_one_box.py index 9f7238c628518..3ba369e57b5b0 100644 --- a/py/test/selenium/webdriver/common/google_one_box.py +++ b/py/test/selenium/webdriver/common/google_one_box.py @@ -15,10 +15,11 @@ # specific language governing permissions and limitations # under the License. +from page_loader import require_loaded +from results_page import ResultsPage + from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.by import By -from results_page import ResultsPage -from page_loader import require_loaded class GoogleOneBox: diff --git a/py/test/selenium/webdriver/common/interactions_tests.py b/py/test/selenium/webdriver/common/interactions_tests.py index 0f2869ce54b46..0e99f4c1b2587 100644 --- a/py/test/selenium/webdriver/common/interactions_tests.py +++ b/py/test/selenium/webdriver/common/interactions_tests.py @@ -17,13 +17,13 @@ """Tests for advanced user interactions.""" import pytest + from selenium.common.exceptions import MoveTargetOutOfBoundsException +from selenium.webdriver.common.action_chains import ActionChains +from selenium.webdriver.common.actions import interaction from selenium.webdriver.common.actions.wheel_input import ScrollOrigin - from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys -from selenium.webdriver.common.action_chains import ActionChains -from selenium.webdriver.common.actions import interaction from selenium.webdriver.support.ui import WebDriverWait diff --git a/py/test/selenium/webdriver/common/proxy_tests.py b/py/test/selenium/webdriver/common/proxy_tests.py index 145493cad7c30..ee1caccdf699c 100755 --- a/py/test/selenium/webdriver/common/proxy_tests.py +++ b/py/test/selenium/webdriver/common/proxy_tests.py @@ -17,8 +17,8 @@ import pytest -from selenium.webdriver.common.proxy import Proxy, ProxyType - +from selenium.webdriver.common.proxy import Proxy +from selenium.webdriver.common.proxy import ProxyType MANUAL_PROXY = { 'httpProxy': 'some.url:1234', diff --git a/py/test/selenium/webdriver/common/select_class_tests.py b/py/test/selenium/webdriver/common/select_class_tests.py index 2126df50f3990..f69f5f946a2aa 100644 --- a/py/test/selenium/webdriver/common/select_class_tests.py +++ b/py/test/selenium/webdriver/common/select_class_tests.py @@ -17,11 +17,10 @@ import pytest -from selenium.common.exceptions import ( - NoSuchElementException, - UnexpectedTagNameException) -from selenium.webdriver.support.ui import Select +from selenium.common.exceptions import NoSuchElementException +from selenium.common.exceptions import UnexpectedTagNameException from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import Select disabledSelect = {'name': 'no-select', 'values': ['Foo']} disabledSingleSelect = {'name': 'single_disabled', 'values': ['Enabled', 'Disabled']} diff --git a/py/test/selenium/webdriver/common/stale_reference_tests.py b/py/test/selenium/webdriver/common/stale_reference_tests.py index 2ac5c7ed70369..b846bb5e91329 100644 --- a/py/test/selenium/webdriver/common/stale_reference_tests.py +++ b/py/test/selenium/webdriver/common/stale_reference_tests.py @@ -17,8 +17,8 @@ import pytest -from selenium.webdriver.common.by import By from selenium.common.exceptions import StaleElementReferenceException +from selenium.webdriver.common.by import By def test_old_page(driver, pages): diff --git a/py/test/selenium/webdriver/common/text_handling_tests.py b/py/test/selenium/webdriver/common/text_handling_tests.py index 4273d9727d3ca..e31d522305190 100644 --- a/py/test/selenium/webdriver/common/text_handling_tests.py +++ b/py/test/selenium/webdriver/common/text_handling_tests.py @@ -19,7 +19,6 @@ from selenium.webdriver.common.by import By - newLine = "\n" diff --git a/py/test/selenium/webdriver/common/typing_tests.py b/py/test/selenium/webdriver/common/typing_tests.py index cb99f5379e75a..62744a1798963 100644 --- a/py/test/selenium/webdriver/common/typing_tests.py +++ b/py/test/selenium/webdriver/common/typing_tests.py @@ -15,11 +15,11 @@ # specific language governing permissions and limitations # under the License. +import pytest + from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys -import pytest - def test_should_fire_key_press_events(driver, pages): pages.load("javascriptPage.html") diff --git a/py/test/selenium/webdriver/common/upload_tests.py b/py/test/selenium/webdriver/common/upload_tests.py index f6edda73199c9..59fa95d760430 100644 --- a/py/test/selenium/webdriver/common/upload_tests.py +++ b/py/test/selenium/webdriver/common/upload_tests.py @@ -16,7 +16,9 @@ # under the License. import os + import pytest + from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement diff --git a/py/test/selenium/webdriver/common/virtual_authenticator_tests.py b/py/test/selenium/webdriver/common/virtual_authenticator_tests.py index 914bba375baed..3d3faba64b99a 100644 --- a/py/test/selenium/webdriver/common/virtual_authenticator_tests.py +++ b/py/test/selenium/webdriver/common/virtual_authenticator_tests.py @@ -15,17 +15,17 @@ # specific language governing permissions and limitations # under the License. +from base64 import b64decode +from base64 import urlsafe_b64decode +from base64 import urlsafe_b64encode from typing import List + import pytest -from base64 import b64decode, urlsafe_b64decode, urlsafe_b64encode from selenium.common.exceptions import InvalidArgumentException +from selenium.webdriver.common.virtual_authenticator import Credential +from selenium.webdriver.common.virtual_authenticator import VirtualAuthenticatorOptions from selenium.webdriver.remote.webdriver import WebDriver -from selenium.webdriver.common.virtual_authenticator import ( - Credential, - VirtualAuthenticatorOptions, -) - # working Key BASE64__ENCODED_PK = ''' diff --git a/py/test/selenium/webdriver/common/visibility_tests.py b/py/test/selenium/webdriver/common/visibility_tests.py index fbbecb588f1c6..1e5ea6f44a8be 100644 --- a/py/test/selenium/webdriver/common/visibility_tests.py +++ b/py/test/selenium/webdriver/common/visibility_tests.py @@ -17,10 +17,8 @@ import pytest - -from selenium.common.exceptions import ( - ElementNotVisibleException, - ElementNotInteractableException) +from selenium.common.exceptions import ElementNotInteractableException +from selenium.common.exceptions import ElementNotVisibleException from selenium.webdriver.common.by import By diff --git a/py/test/selenium/webdriver/common/w3c_interaction_tests.py b/py/test/selenium/webdriver/common/w3c_interaction_tests.py index cc49de63e320a..0bf9d65bdbcc6 100644 --- a/py/test/selenium/webdriver/common/w3c_interaction_tests.py +++ b/py/test/selenium/webdriver/common/w3c_interaction_tests.py @@ -17,12 +17,12 @@ import pytest -from selenium.webdriver.common.actions.wheel_input import WheelInput -from selenium.webdriver.common.keys import Keys +from selenium.webdriver.common.actions import interaction from selenium.webdriver.common.actions.action_builder import ActionBuilder from selenium.webdriver.common.actions.pointer_input import PointerInput -from selenium.webdriver.common.actions import interaction +from selenium.webdriver.common.actions.wheel_input import WheelInput from selenium.webdriver.common.by import By +from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait diff --git a/py/test/selenium/webdriver/common/web_components_tests.py b/py/test/selenium/webdriver/common/web_components_tests.py index 0e91aa16e066b..c1d5120c15f49 100644 --- a/py/test/selenium/webdriver/common/web_components_tests.py +++ b/py/test/selenium/webdriver/common/web_components_tests.py @@ -19,8 +19,8 @@ from selenium.common.exceptions import NoSuchShadowRootException from selenium.webdriver.common.by import By -from selenium.webdriver.remote.webelement import WebElement from selenium.webdriver.remote.shadowroot import ShadowRoot +from selenium.webdriver.remote.webelement import WebElement @pytest.mark.xfail_safari diff --git a/py/test/selenium/webdriver/common/webdriverwait_tests.py b/py/test/selenium/webdriver/common/webdriverwait_tests.py index 475089e0a81a9..4b68587d31766 100644 --- a/py/test/selenium/webdriver/common/webdriverwait_tests.py +++ b/py/test/selenium/webdriver/common/webdriverwait_tests.py @@ -19,10 +19,11 @@ import pytest -from selenium.common.exceptions import TimeoutException, InvalidSelectorException +from selenium.common.exceptions import InvalidElementStateException +from selenium.common.exceptions import InvalidSelectorException from selenium.common.exceptions import StaleElementReferenceException +from selenium.common.exceptions import TimeoutException from selenium.common.exceptions import WebDriverException -from selenium.common.exceptions import InvalidElementStateException from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait diff --git a/py/test/selenium/webdriver/common/webserver.py b/py/test/selenium/webdriver/common/webserver.py index c2c7ac41b18e4..c84cfa1276be9 100644 --- a/py/test/selenium/webdriver/common/webserver.py +++ b/py/test/selenium/webdriver/common/webserver.py @@ -22,15 +22,18 @@ import os import re import threading + try: from urllib import request as urllib_request except ImportError: import urllib as urllib_request try: - from http.server import BaseHTTPRequestHandler, HTTPServer + from http.server import BaseHTTPRequestHandler + from http.server import HTTPServer from socketserver import ThreadingMixIn except ImportError: - from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer + from BaseHTTPServer import BaseHTTPRequestHandler + from BaseHTTPServer import HTTPServer from SocketServer import ThreadingMixIn diff --git a/py/test/selenium/webdriver/common/window_tests.py b/py/test/selenium/webdriver/common/window_tests.py index 90b1015d5ae1a..bd1a6e66ec3af 100644 --- a/py/test/selenium/webdriver/common/window_tests.py +++ b/py/test/selenium/webdriver/common/window_tests.py @@ -20,7 +20,6 @@ from selenium.common.exceptions import WebDriverException from selenium.webdriver.support.wait import WebDriverWait - # @pytest.mark.xfail_ie # @pytest.mark.xfail_chromiumedge(reason="Fails on Travis") # @pytest.mark.xfail_firefox(reason="Fails on Travis") diff --git a/py/test/selenium/webdriver/ie/ie_launcher_tests.py b/py/test/selenium/webdriver/ie/ie_launcher_tests.py index 88d627f083daf..4b9b82fcfcfe0 100755 --- a/py/test/selenium/webdriver/ie/ie_launcher_tests.py +++ b/py/test/selenium/webdriver/ie/ie_launcher_tests.py @@ -16,8 +16,8 @@ # under the License. from selenium.webdriver import Ie -from selenium.webdriver.ie.options import Options from selenium.webdriver.common.desired_capabilities import DesiredCapabilities +from selenium.webdriver.ie.options import Options def test_launch_and_close_browser(): diff --git a/py/test/selenium/webdriver/marionette/mn_options_tests.py b/py/test/selenium/webdriver/marionette/mn_options_tests.py index 4e7293ee70b62..5870425e938f2 100644 --- a/py/test/selenium/webdriver/marionette/mn_options_tests.py +++ b/py/test/selenium/webdriver/marionette/mn_options_tests.py @@ -17,12 +17,12 @@ import pytest - from selenium.webdriver.common.by import By from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.firefox.firefox_binary import FirefoxBinary from selenium.webdriver.firefox.firefox_profile import FirefoxProfile -from selenium.webdriver.firefox.options import Log, Options +from selenium.webdriver.firefox.options import Log +from selenium.webdriver.firefox.options import Options @pytest.fixture diff --git a/py/test/selenium/webdriver/remote/remote_firefox_profile_tests.py b/py/test/selenium/webdriver/remote/remote_firefox_profile_tests.py index 5e60db95224ea..09184e436836a 100644 --- a/py/test/selenium/webdriver/remote/remote_firefox_profile_tests.py +++ b/py/test/selenium/webdriver/remote/remote_firefox_profile_tests.py @@ -16,6 +16,7 @@ # under the License. import pytest + from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities diff --git a/py/test/selenium/webdriver/remote/remote_hub_connection.py b/py/test/selenium/webdriver/remote/remote_hub_connection.py index 4170a21f3d49a..48616399be8d3 100644 --- a/py/test/selenium/webdriver/remote/remote_hub_connection.py +++ b/py/test/selenium/webdriver/remote/remote_hub_connection.py @@ -17,6 +17,7 @@ import pytest import urllib3 + from selenium import webdriver diff --git a/py/test/selenium/webdriver/support/event_firing_webdriver_tests.py b/py/test/selenium/webdriver/support/event_firing_webdriver_tests.py index e9f5e7e1e4a84..22399b50017c4 100644 --- a/py/test/selenium/webdriver/support/event_firing_webdriver_tests.py +++ b/py/test/selenium/webdriver/support/event_firing_webdriver_tests.py @@ -21,10 +21,11 @@ import pytest from selenium.common.exceptions import NoSuchElementException +from selenium.webdriver.common.actions.action_builder import ActionBuilder from selenium.webdriver.common.by import By -from selenium.webdriver.support.events import EventFiringWebDriver, AbstractEventListener +from selenium.webdriver.support.events import AbstractEventListener +from selenium.webdriver.support.events import EventFiringWebDriver from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.common.actions.action_builder import ActionBuilder @pytest.fixture diff --git a/py/test/selenium/webdriver/support/expected_conditions_tests.py b/py/test/selenium/webdriver/support/expected_conditions_tests.py index dabbaff51a29a..2e04a6e9f03e0 100644 --- a/py/test/selenium/webdriver/support/expected_conditions_tests.py +++ b/py/test/selenium/webdriver/support/expected_conditions_tests.py @@ -18,10 +18,10 @@ import pytest from selenium.common.exceptions import TimeoutException -from selenium.webdriver.support.wait import WebDriverWait -from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.support.wait import WebDriverWait def test_any_of_true(driver, pages): diff --git a/py/test/selenium/webdriver/support/relative_by_tests.py b/py/test/selenium/webdriver/support/relative_by_tests.py index 9573c9695537d..7c4ee24e96e3c 100644 --- a/py/test/selenium/webdriver/support/relative_by_tests.py +++ b/py/test/selenium/webdriver/support/relative_by_tests.py @@ -14,10 +14,12 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +import pytest + from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.by import By -from selenium.webdriver.support.relative_locator import with_tag_name, locate_with -import pytest +from selenium.webdriver.support.relative_locator import locate_with +from selenium.webdriver.support.relative_locator import with_tag_name def test_should_be_able_to_find_first_one(driver, pages): diff --git a/py/test/unit/selenium/webdriver/firefox/firefox_options_tests.py b/py/test/unit/selenium/webdriver/firefox/firefox_options_tests.py index 2f43937d9613c..8f3e81a797186 100644 --- a/py/test/unit/selenium/webdriver/firefox/firefox_options_tests.py +++ b/py/test/unit/selenium/webdriver/firefox/firefox_options_tests.py @@ -18,7 +18,8 @@ import pytest from selenium.common.exceptions import InvalidArgumentException -from selenium.webdriver.common.proxy import Proxy, ProxyType +from selenium.webdriver.common.proxy import Proxy +from selenium.webdriver.common.proxy import ProxyType from selenium.webdriver.firefox.firefox_binary import FirefoxBinary from selenium.webdriver.firefox.firefox_profile import FirefoxProfile from selenium.webdriver.firefox.options import Options diff --git a/py/test/unit/selenium/webdriver/ie/test_ie_options.py b/py/test/unit/selenium/webdriver/ie/test_ie_options.py index c0a2a329c688c..041ca6edf8b9f 100644 --- a/py/test/unit/selenium/webdriver/ie/test_ie_options.py +++ b/py/test/unit/selenium/webdriver/ie/test_ie_options.py @@ -16,9 +16,11 @@ # under the License. -from selenium.webdriver.ie.options import Options, ElementScrollBehavior import pytest +from selenium.webdriver.ie.options import ElementScrollBehavior +from selenium.webdriver.ie.options import Options + TIMEOUT = 30 diff --git a/py/test/unit/selenium/webdriver/remote/error_handler_tests.py b/py/test/unit/selenium/webdriver/remote/error_handler_tests.py index 3c0ea3143b0ab..3700586c453f2 100644 --- a/py/test/unit/selenium/webdriver/remote/error_handler_tests.py +++ b/py/test/unit/selenium/webdriver/remote/error_handler_tests.py @@ -18,7 +18,8 @@ import pytest from selenium.common import exceptions -from selenium.webdriver.remote.errorhandler import ErrorCode, ErrorHandler +from selenium.webdriver.remote.errorhandler import ErrorCode +from selenium.webdriver.remote.errorhandler import ErrorHandler @pytest.fixture diff --git a/py/test/unit/selenium/webdriver/remote/remote_connection_tests.py b/py/test/unit/selenium/webdriver/remote/remote_connection_tests.py index 4cbd765e73ef6..aaddc396eb933 100644 --- a/py/test/unit/selenium/webdriver/remote/remote_connection_tests.py +++ b/py/test/unit/selenium/webdriver/remote/remote_connection_tests.py @@ -21,9 +21,7 @@ import urllib3 from selenium import __version__ -from selenium.webdriver.remote.remote_connection import ( - RemoteConnection, -) +from selenium.webdriver.remote.remote_connection import RemoteConnection def test_get_remote_connection_headers_defaults(): diff --git a/py/test/unit/selenium/webdriver/remote/subtyping_tests.py b/py/test/unit/selenium/webdriver/remote/subtyping_tests.py index c2d027222168b..90310dfc12856 100644 --- a/py/test/unit/selenium/webdriver/remote/subtyping_tests.py +++ b/py/test/unit/selenium/webdriver/remote/subtyping_tests.py @@ -16,8 +16,8 @@ # under the License. -from selenium.webdriver.remote.webdriver import WebElement from selenium.webdriver.remote.webdriver import WebDriver +from selenium.webdriver.remote.webdriver import WebElement def test_web_element_not_subclassed(): diff --git a/py/test/unit/selenium/webdriver/virtual_authenticator/credentials_test.py b/py/test/unit/selenium/webdriver/virtual_authenticator/credentials_test.py index 55e22840fda4f..fb629a6313639 100644 --- a/py/test/unit/selenium/webdriver/virtual_authenticator/credentials_test.py +++ b/py/test/unit/selenium/webdriver/virtual_authenticator/credentials_test.py @@ -15,13 +15,14 @@ # specific language governing permissions and limitations # under the License. +from base64 import urlsafe_b64decode +from base64 import urlsafe_b64encode +from typing import Tuple + import pytest -from typing import Tuple -from base64 import urlsafe_b64decode, urlsafe_b64encode from selenium.webdriver.common.virtual_authenticator import Credential - BASE64__ENCODED_PK = ''' MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDbBOu5Lhs4vpowbCnmCyLUpIE7JM9sm9QXzye2G+jr+Kr MsinWohEce47BFPJlTaDzHSvOW2eeunBO89ZcvvVc8RLz4qyQ8rO98xS1jtgqi1NcBPETDrtzthODu/gd0sjB2Tk3TLuBGV diff --git a/py/test/unit/selenium/webdriver/virtual_authenticator/virtual_authenticator_options_tests.py b/py/test/unit/selenium/webdriver/virtual_authenticator/virtual_authenticator_options_tests.py index d99427765b41e..56ce050915d42 100644 --- a/py/test/unit/selenium/webdriver/virtual_authenticator/virtual_authenticator_options_tests.py +++ b/py/test/unit/selenium/webdriver/virtual_authenticator/virtual_authenticator_options_tests.py @@ -17,10 +17,7 @@ import pytest - -from selenium.webdriver.common.virtual_authenticator import ( - VirtualAuthenticatorOptions, -) +from selenium.webdriver.common.virtual_authenticator import VirtualAuthenticatorOptions @pytest.fixture diff --git a/py/tox.ini b/py/tox.ini index 33ab9e66fd76c..1d89ef56ee416 100644 --- a/py/tox.ini +++ b/py/tox.ini @@ -31,11 +31,11 @@ commands = mypy {posargs} ; files or individual lines can be ignored via `# isort:skip|# isort:skip_file`. ; this is using --diff which is a NO-OP, requires additional discussion / approval being enabled. profile = black -multi_line_output = 3 py_version=37 +force_single_line = True [testenv:isort] skip_install = true deps = isort==5.10.1 -commands = isort test/ --diff +commands = isort selenium/ test/