Skip to content

Commit 739e52b

Browse files
committed
fix type more
1 parent 11f2ba1 commit 739e52b

File tree

4 files changed

+10
-20
lines changed

4 files changed

+10
-20
lines changed

appium/webdriver/common/appiumby.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ class AppiumBy(By):
4949
'-flutter semantics label',
5050
'-flutter type',
5151
'-flutter key',
52+
'-flutter text',
5253
'-flutter text containing',
5354
]

appium/webdriver/extensions/flutter_integration/flutter_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def execute_flutter_command(self, scriptName: str, params: dict) -> Any:
290290
"""
291291
return self.driver.execute_script(f'flutter: {scriptName}', params)
292292

293-
def __get_locator_options(self, locator: Union[WebElement, 'FlutterFinder']) -> Dict[str, dict]:
293+
def __get_locator_options(self, locator: Union[WebElement, 'FlutterFinder']) -> Dict[str, Union[dict, WebElement]]:
294294
if isinstance(locator, WebElement):
295295
return {'element': locator}
296296
return {'locator': locator.to_dict()}

appium/webdriver/extensions/flutter_integration/flutter_finder.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from typing import Tuple, Union
18+
from typing import Tuple, Union, cast
1919

2020
from selenium.webdriver.common.by import ByType as SeleniumByType
2121

@@ -30,23 +30,23 @@ def __init__(self, using: Union[SeleniumByType, AppiumByType], value: str) -> No
3030

3131
@staticmethod
3232
def by_key(value: str) -> 'FlutterFinder':
33-
return FlutterFinder(AppiumBy.FLUTTER_INTEGRATION_KEY, value)
33+
return FlutterFinder(cast(AppiumByType, AppiumBy.FLUTTER_INTEGRATION_KEY), value)
3434

3535
@staticmethod
3636
def by_text(value: str) -> 'FlutterFinder':
37-
return FlutterFinder(AppiumBy.FLUTTER_INTEGRATION_TEXT, value)
37+
return FlutterFinder(cast(AppiumByType, AppiumBy.FLUTTER_INTEGRATION_TEXT), value)
3838

3939
@staticmethod
4040
def by_semantics_label(value: str) -> 'FlutterFinder':
41-
return FlutterFinder(AppiumBy.FLUTTER_INTEGRATION_SEMANTICS_LABEL, value)
41+
return FlutterFinder(cast(AppiumByType, AppiumBy.FLUTTER_INTEGRATION_SEMANTICS_LABEL), value)
4242

4343
@staticmethod
4444
def by_type(value: str) -> 'FlutterFinder':
45-
return FlutterFinder(AppiumBy.FLUTTER_INTEGRATION_TYPE, value)
45+
return FlutterFinder(cast(AppiumByType, AppiumBy.FLUTTER_INTEGRATION_TYPE), value)
4646

4747
@staticmethod
4848
def by_text_containing(value: str) -> 'FlutterFinder':
49-
return FlutterFinder(AppiumBy.FLUTTER_INTEGRATION_TEXT_CONTAINING, value)
49+
return FlutterFinder(cast(AppiumByType, AppiumBy.FLUTTER_INTEGRATION_TEXT_CONTAINING), value)
5050

5151
def to_dict(self) -> dict:
5252
return {'using': self.using, 'value': self.value}

appium/webdriver/webdriver.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Set, Tuple, Union
15+
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Set, Tuple, Type, Union
1616

1717
from selenium import webdriver
1818
from selenium.common.exceptions import (
@@ -21,14 +21,12 @@
2121
UnknownMethodException,
2222
WebDriverException,
2323
)
24-
from selenium.webdriver.common.by import By
2524
from selenium.webdriver.remote.command import Command as RemoteCommand
2625
from selenium.webdriver.remote.remote_connection import RemoteConnection
2726
from typing_extensions import Self
2827

2928
from appium.common.logger import logger
3029
from appium.options.common.base import AppiumOptions
31-
from appium.webdriver.common.appiumby import AppiumBy
3230

3331
from .appium_connection import AppiumConnection
3432
from .client_config import AppiumClientConfig
@@ -241,7 +239,7 @@ class WebDriver(
241239
def __init__(
242240
self,
243241
command_executor: Union[str, AppiumConnection] = 'http://127.0.0.1:4723',
244-
extensions: Optional[List['WebDriver']] = None,
242+
extensions: Optional[List[Type['ExtensionBase']]] = None,
245243
options: Union[AppiumOptions, List[AppiumOptions], None] = None,
246244
client_config: Optional[AppiumClientConfig] = None,
247245
):
@@ -266,15 +264,6 @@ def __init__(
266264
if client_config and client_config.direct_connection:
267265
self._update_command_executor(keep_alive=client_config.keep_alive)
268266

269-
# add new method to the `find_by_*` pantheon
270-
By.IOS_PREDICATE = AppiumBy.IOS_PREDICATE
271-
By.IOS_CLASS_CHAIN = AppiumBy.IOS_CLASS_CHAIN
272-
By.ANDROID_UIAUTOMATOR = AppiumBy.ANDROID_UIAUTOMATOR
273-
By.ANDROID_VIEWTAG = AppiumBy.ANDROID_VIEWTAG
274-
By.ACCESSIBILITY_ID = AppiumBy.ACCESSIBILITY_ID
275-
By.IMAGE = AppiumBy.IMAGE
276-
By.CUSTOM = AppiumBy.CUSTOM
277-
278267
self._absent_extensions: Set[str] = set()
279268

280269
self._extensions = extensions or []

0 commit comments

Comments
 (0)