Skip to content

Commit da595d6

Browse files
committed
fix review, extract locator_converter
1 parent b458679 commit da595d6

File tree

4 files changed

+33
-15
lines changed

4 files changed

+33
-15
lines changed

appium/webdriver/appium_connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
def _get_new_headers(key: str, headers: Dict[str, str]) -> Dict[str, str]:
3232
"""Return a new dictionary of heafers without the given key.
3333
The key match is case-insensitive."""
34-
key = key.lower()
35-
return {k: v for k, v in headers.items() if k.lower() != key}
34+
lower_key = key.lower()
35+
return {k: v for k, v in headers.items() if k.lower() != lower_key}
3636

3737

3838
class AppiumConnection(RemoteConnection):
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from typing import Tuple
16+
17+
from selenium.webdriver.remote.locator_converter import LocatorConverter
18+
19+
20+
class AppiumLocatorConverter(LocatorConverter):
21+
"""A custom locator converter in Appium.
22+
23+
Appium supports locators which are not defined in W3C WebDriver,
24+
so Appium Python client wants to keep the given locators
25+
to the Appium server as-is.
26+
"""
27+
28+
def convert(self, by: str, value: str) -> Tuple[str, str]:
29+
return (by, value)

appium/webdriver/webdriver.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,12 @@
5858
from .extensions.screen_record import ScreenRecord
5959
from .extensions.session import Session
6060
from .extensions.settings import Settings
61+
from .locator_converter import AppiumLocatorConverter
6162
from .mobilecommand import MobileCommand as Command
6263
from .switch_to import MobileSwitchTo
6364
from .webelement import WebElement as MobileWebElement
6465

6566

66-
class AppiumLocatorConverter:
67-
"""A custom locator converter in Appium.
68-
69-
Appium supports locators which are not defined in W3C WebDriver,
70-
so Appium Python client wants to keep the given locators
71-
to the Appium server as-is.
72-
"""
73-
74-
def convert(self, by: str, value: str) -> Tuple[str, str]:
75-
return (by, value)
76-
77-
7867
class ExtensionBase:
7968
"""
8069
Used to define an extension command as driver's methods.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@
4949
'Topic :: Software Development :: Quality Assurance',
5050
'Topic :: Software Development :: Testing',
5151
],
52-
install_requires=['selenium ~= 4.26'],
52+
install_requires=['selenium ~= 4.26, < 5.0'],
5353
)

0 commit comments

Comments
 (0)