diff --git a/appium/webdriver/appium_connection.py b/appium/webdriver/appium_connection.py index be7c7058..388f860d 100644 --- a/appium/webdriver/appium_connection.py +++ b/appium/webdriver/appium_connection.py @@ -31,8 +31,8 @@ def _get_new_headers(key: str, headers: Dict[str, str]) -> Dict[str, str]: """Return a new dictionary of heafers without the given key. The key match is case-insensitive.""" - key = key.lower() - return {k: v for k, v in headers.items() if k.lower() != key} + lower_key = key.lower() + return {k: v for k, v in headers.items() if k.lower() != lower_key} class AppiumConnection(RemoteConnection): diff --git a/appium/webdriver/locator_converter.py b/appium/webdriver/locator_converter.py new file mode 100644 index 00000000..4c6416c6 --- /dev/null +++ b/appium/webdriver/locator_converter.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import Tuple + +from selenium.webdriver.remote.locator_converter import LocatorConverter + + +class AppiumLocatorConverter(LocatorConverter): + """A custom locator converter in Appium. + + Appium supports locators which are not defined in W3C WebDriver, + so Appium Python client wants to keep the given locators + to the Appium server as-is. + """ + + def convert(self, by: str, value: str) -> Tuple[str, str]: + return (by, value) diff --git a/appium/webdriver/webdriver.py b/appium/webdriver/webdriver.py index 5d785e24..200d5f91 100644 --- a/appium/webdriver/webdriver.py +++ b/appium/webdriver/webdriver.py @@ -58,23 +58,12 @@ from .extensions.screen_record import ScreenRecord from .extensions.session import Session from .extensions.settings import Settings +from .locator_converter import AppiumLocatorConverter from .mobilecommand import MobileCommand as Command from .switch_to import MobileSwitchTo from .webelement import WebElement as MobileWebElement -class AppiumLocatorConverter: - """A custom locator converter in Appium. - - Appium supports locators which are not defined in W3C WebDriver, - so Appium Python client wants to keep the given locators - to the Appium server as-is. - """ - - def convert(self, by: str, value: str) -> Tuple[str, str]: - return (by, value) - - class ExtensionBase: """ Used to define an extension command as driver's methods. diff --git a/setup.py b/setup.py index 395c03af..35ce5b9f 100644 --- a/setup.py +++ b/setup.py @@ -49,5 +49,5 @@ 'Topic :: Software Development :: Quality Assurance', 'Topic :: Software Development :: Testing', ], - install_requires=['selenium ~= 4.26'], + install_requires=['selenium ~= 4.26, < 5.0'], )