Appium-Python-Client 6.1.4__py3-none-any.whl → 6.1.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,9 +14,9 @@
14
14
 
15
15
  from typing import TYPE_CHECKING, Protocol, runtime_checkable
16
16
 
17
- if TYPE_CHECKING:
18
- from selenium.webdriver.common.by import By
17
+ from selenium.webdriver.common.by import By
19
18
 
19
+ if TYPE_CHECKING:
20
20
  from appium.webdriver.webelement import WebElement
21
21
 
22
22
 
@@ -29,13 +29,6 @@ class CanFindElements(Protocol):
29
29
  - find_elements(by, value): Find multiple elements
30
30
  """
31
31
 
32
- if TYPE_CHECKING:
33
-
34
- def find_element(self, by: str = By.ID, value: str | dict | None = None) -> 'WebElement': ...
35
-
36
- def find_elements(self, by: str = By.ID, value: str | dict | None = None) -> list['WebElement']: ...
37
- else:
38
-
39
- def find_element(self, by: str = 'id', value: str | dict | None = None) -> 'WebElement': ...
32
+ def find_element(self, by: str | By = By.ID, value: str | dict | None = None) -> 'WebElement': ...
40
33
 
41
- def find_elements(self, by: str = 'id', value: str | dict | None = None) -> list['WebElement']: ...
34
+ def find_elements(self, by: str | By = By.ID, value: str | dict | None = None) -> list['WebElement']: ...
@@ -16,26 +16,6 @@ from typing import Literal
16
16
 
17
17
  from selenium.webdriver.common.by import By
18
18
 
19
-
20
- class AppiumBy(By):
21
- IOS_PREDICATE = '-ios predicate string'
22
- IOS_CLASS_CHAIN = '-ios class chain'
23
- ANDROID_UIAUTOMATOR = '-android uiautomator'
24
- ANDROID_VIEWTAG = '-android viewtag'
25
- ANDROID_DATA_MATCHER = '-android datamatcher'
26
- ANDROID_VIEW_MATCHER = '-android viewmatcher'
27
- ACCESSIBILITY_ID = 'accessibility id'
28
- IMAGE = '-image'
29
- CUSTOM = '-custom'
30
-
31
- # For Flutter integration usage https://github.com/AppiumTestDistribution/appium-flutter-integration-driver/tree/main
32
- FLUTTER_INTEGRATION_SEMANTICS_LABEL = '-flutter semantics label'
33
- FLUTTER_INTEGRATION_TYPE = '-flutter type'
34
- FLUTTER_INTEGRATION_KEY = '-flutter key'
35
- FLUTTER_INTEGRATION_TEXT = '-flutter text'
36
- FLUTTER_INTEGRATION_TEXT_CONTAINING = '-flutter text containing'
37
-
38
-
39
19
  ByType = Literal[
40
20
  '-ios predicate string',
41
21
  '-ios class chain',
@@ -52,3 +32,22 @@ ByType = Literal[
52
32
  '-flutter text',
53
33
  '-flutter text containing',
54
34
  ]
35
+
36
+
37
+ class AppiumBy(By):
38
+ IOS_PREDICATE: ByType = '-ios predicate string'
39
+ IOS_CLASS_CHAIN: ByType = '-ios class chain'
40
+ ANDROID_UIAUTOMATOR: ByType = '-android uiautomator'
41
+ ANDROID_VIEWTAG: ByType = '-android viewtag'
42
+ ANDROID_DATA_MATCHER: ByType = '-android datamatcher'
43
+ ANDROID_VIEW_MATCHER: ByType = '-android viewmatcher'
44
+ ACCESSIBILITY_ID: ByType = 'accessibility id'
45
+ IMAGE: ByType = '-image'
46
+ CUSTOM: ByType = '-custom'
47
+
48
+ # For Flutter integration usage https://github.com/AppiumTestDistribution/appium-flutter-integration-driver/tree/main
49
+ FLUTTER_INTEGRATION_SEMANTICS_LABEL: ByType = '-flutter semantics label'
50
+ FLUTTER_INTEGRATION_TYPE: ByType = '-flutter type'
51
+ FLUTTER_INTEGRATION_KEY: ByType = '-flutter key'
52
+ FLUTTER_INTEGRATION_TEXT: ByType = '-flutter text'
53
+ FLUTTER_INTEGRATION_TEXT_CONTAINING: ByType = '-flutter text containing'
@@ -15,8 +15,6 @@
15
15
  # specific language governing permissions and limitations
16
16
  # under the License.
17
17
 
18
- from typing import cast
19
-
20
18
  from selenium.webdriver.common.by import ByType as SeleniumByType
21
19
 
22
20
  from appium.webdriver.common.appiumby import AppiumBy
@@ -30,23 +28,23 @@ class FlutterFinder:
30
28
 
31
29
  @staticmethod
32
30
  def by_key(value: str) -> 'FlutterFinder':
33
- return FlutterFinder(cast(AppiumByType, AppiumBy.FLUTTER_INTEGRATION_KEY), value)
31
+ return FlutterFinder(AppiumBy.FLUTTER_INTEGRATION_KEY, value)
34
32
 
35
33
  @staticmethod
36
34
  def by_text(value: str) -> 'FlutterFinder':
37
- return FlutterFinder(cast(AppiumByType, AppiumBy.FLUTTER_INTEGRATION_TEXT), value)
35
+ return FlutterFinder(AppiumBy.FLUTTER_INTEGRATION_TEXT, value)
38
36
 
39
37
  @staticmethod
40
38
  def by_semantics_label(value: str) -> 'FlutterFinder':
41
- return FlutterFinder(cast(AppiumByType, AppiumBy.FLUTTER_INTEGRATION_SEMANTICS_LABEL), value)
39
+ return FlutterFinder(AppiumBy.FLUTTER_INTEGRATION_SEMANTICS_LABEL, value)
42
40
 
43
41
  @staticmethod
44
42
  def by_type(value: str) -> 'FlutterFinder':
45
- return FlutterFinder(cast(AppiumByType, AppiumBy.FLUTTER_INTEGRATION_TYPE), value)
43
+ return FlutterFinder(AppiumBy.FLUTTER_INTEGRATION_TYPE, value)
46
44
 
47
45
  @staticmethod
48
46
  def by_text_containing(value: str) -> 'FlutterFinder':
49
- return FlutterFinder(cast(AppiumByType, AppiumBy.FLUTTER_INTEGRATION_TEXT_CONTAINING), value)
47
+ return FlutterFinder(AppiumBy.FLUTTER_INTEGRATION_TEXT_CONTAINING, value)
50
48
 
51
49
  def to_dict(self) -> dict:
52
50
  return {'using': self.using, 'value': self.value}
@@ -13,13 +13,23 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
+ from typing import TYPE_CHECKING
17
+
16
18
  from selenium.webdriver.remote.switch_to import SwitchTo
17
19
  from typing_extensions import Self
18
20
 
19
21
  from .mobilecommand import MobileCommand
20
22
 
23
+ if TYPE_CHECKING:
24
+ from .webelement import WebElement as MobileWebElement
25
+
21
26
 
22
27
  class MobileSwitchTo(SwitchTo):
28
+ if TYPE_CHECKING:
29
+
30
+ @property
31
+ def active_element(self) -> MobileWebElement: ...
32
+
23
33
  def context(self, context_name: str | None) -> Self:
24
34
  """Sets the context for the current session.
25
35
  Passing `None` is equal to switching to native context.
@@ -28,7 +28,7 @@ from selenium.webdriver.remote.remote_connection import RemoteConnection
28
28
  from selenium.webdriver.remote.webdriver import WebDriver as Remote
29
29
 
30
30
  from appium.common.logger import logger
31
- from appium.options.common.base import AppiumOptions
31
+ from appium.options.common.base import APPIUM_PREFIX, AppiumOptions
32
32
 
33
33
  from .appium_connection import AppiumConnection
34
34
  from .client_config import AppiumClientConfig
@@ -66,6 +66,7 @@ from .webelement import WebElement as MobileWebElement
66
66
 
67
67
  if TYPE_CHECKING:
68
68
  from selenium.webdriver.common.by import By
69
+ from selenium.webdriver.support.relative_locator import RelativeBy
69
70
 
70
71
 
71
72
  class ExtensionBase:
@@ -212,6 +213,14 @@ def _get_remote_connection_and_client_config(
212
213
  return (AppiumConnection(client_config=new_client_config), new_client_config)
213
214
 
214
215
 
216
+ def _get_direct_connect_value(caps: dict[str, Any], key: str) -> Any:
217
+ for candidate in (f'{APPIUM_PREFIX}{key}', key):
218
+ value = caps.get(candidate)
219
+ if value is not None and value != '':
220
+ return value
221
+ return None
222
+
223
+
215
224
  class WebDriver(
216
225
  Remote,
217
226
  ActionHelpers,
@@ -272,8 +281,9 @@ class WebDriver(
272
281
 
273
282
  self.error_handler = MobileErrorHandler()
274
283
 
275
- if client_config and client_config.direct_connection:
276
- self._update_command_executor(keep_alive=client_config.keep_alive)
284
+ effective_client_config = client_config or getattr(self.command_executor, 'client_config', None)
285
+ if isinstance(effective_client_config, AppiumClientConfig) and effective_client_config.direct_connection:
286
+ self._update_command_executor(keep_alive=effective_client_config.keep_alive)
277
287
 
278
288
  self._absent_extensions: set[str] = set()
279
289
 
@@ -291,11 +301,11 @@ class WebDriver(
291
301
 
292
302
  if TYPE_CHECKING:
293
303
 
294
- def find_element(self, by: str = By.ID, value: str | dict | None = None) -> 'MobileWebElement': # type: ignore[override]
295
- ...
304
+ def find_element(self, by: str | By | RelativeBy = By.ID, value: str | dict | None = None) -> 'MobileWebElement': ...
296
305
 
297
- def find_elements(self, by: str = By.ID, value: str | dict | None = None) -> list['MobileWebElement']: # type: ignore[override]
298
- ...
306
+ def find_elements( # type: ignore[override]
307
+ self, by: str | By | RelativeBy = By.ID, value: str | dict | None = None
308
+ ) -> list['MobileWebElement']: ...
299
309
 
300
310
  def delete_extensions(self) -> None:
301
311
  """Delete extensions added in the class with 'setattr'"""
@@ -315,15 +325,16 @@ class WebDriver(
315
325
  if not self.caps:
316
326
  raise ValueError('Driver capabilities must be defined')
317
327
  keys = (direct_protocol, direct_host, direct_port, direct_path)
318
- if not set(keys).issubset(self.caps):
319
- details = ' '.join(f"{key}: '{self.caps.get(key, '')}'" for key in keys)
328
+ values = {key: _get_direct_connect_value(self.caps, key) for key in keys}
329
+ if any(val is None for val in values.values()):
330
+ details = ' '.join(f"{key}: '{values[key] if values[key] is not None else ''}'" for key in keys)
320
331
  logger.debug(f'Direct connect capabilities from server were:\n{details} ')
321
332
  return
322
333
 
323
- protocol = self.caps[direct_protocol]
324
- hostname = self.caps[direct_host]
325
- port = self.caps[direct_port]
326
- path = self.caps[direct_path]
334
+ protocol = values[direct_protocol]
335
+ hostname = values[direct_host]
336
+ port = values[direct_port]
337
+ path = values[direct_path]
327
338
  executor = f'{protocol}://{hostname}:{port}{path}'
328
339
 
329
340
  logger.debug('Updated request endpoint to %s', executor)
@@ -336,8 +347,8 @@ class WebDriver(
336
347
  client_config = copy.copy(self.command_executor.client_config)
337
348
  client_config.remote_server_addr = executor
338
349
  client_config.keep_alive = keep_alive
339
- if isinstance(self.command_executor, AppiumConnection): # type: ignore
340
- self.command_executor = AppiumConnection(client_config=client_config)
350
+ if isinstance(self.command_executor, AppiumConnection):
351
+ self.command_executor = type(self.command_executor)(client_config=client_config)
341
352
  else:
342
353
  self.command_executor = RemoteConnection(client_config=client_config)
343
354
  self._add_commands()
@@ -32,10 +32,9 @@ class WebElement(SeleniumWebElement):
32
32
 
33
33
  if TYPE_CHECKING:
34
34
 
35
- def find_element(self, by: str = By.ID, value: str | dict | None = None) -> Self: # type: ignore[override]
36
- ...
35
+ def find_element(self, by: str | By = By.ID, value: str | dict | None = None) -> Self: ...
37
36
 
38
- def find_elements(self, by: str = By.ID, value: str | dict | None = None) -> list[Self]: # type: ignore[override]
37
+ def find_elements(self, by: str | By = By.ID, value: str | dict | None = None) -> list[Self]: # type: ignore[override]
39
38
  ...
40
39
 
41
40
  def get_attribute(self, name: str) -> str | dict | None: # type: ignore[override]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: Appium-Python-Client
3
- Version: 6.1.4
3
+ Version: 6.1.6
4
4
  Summary: Python client for Appium
5
5
  Project-URL: Homepage, https://appium.io/
6
6
  Project-URL: Repository, https://github.com/appium/python-client
@@ -319,12 +319,12 @@ any | `appium.options.common.base.AppiumOptions`
319
319
 
320
320
  ## Direct Connect URLs
321
321
 
322
- If your Selenium/Appium server decorates the new session capabilities response with the following keys:
322
+ If your Selenium/Appium server decorates the new session capabilities response with the following keys (with or without the `appium:` prefix):
323
323
 
324
- - `directConnectProtocol`
325
- - `directConnectHost`
326
- - `directConnectPort`
327
- - `directConnectPath`
324
+ - `directConnectProtocol` (`appium:directConnectProtocol`)
325
+ - `directConnectHost` (`appium:directConnectHost`)
326
+ - `directConnectPort` (`appium:directConnectPort`)
327
+ - `directConnectPath` (`appium:directConnectPath`)
328
328
 
329
329
  Then python client will switch its endpoint to the one specified by the values of those keys.
330
330
 
@@ -269,7 +269,7 @@ appium/protocols/__init__.py,sha256=wSUl6yC2TJNla7xbHXkCfn9J1LpQs9UIx8oOs6V8kZA,
269
269
  appium/protocols/webdriver/__init__.py,sha256=wSUl6yC2TJNla7xbHXkCfn9J1LpQs9UIx8oOs6V8kZA,567
270
270
  appium/protocols/webdriver/can_execute_commands.py,sha256=l6Wq-yL-hzCek9djetnrfp8VX62Fw9o4hNcisBDUEWE,832
271
271
  appium/protocols/webdriver/can_execute_scripts.py,sha256=dMRDjreiyV3IJp7-NRUx1TjouOu34mLUa9N6qZPq3b0,962
272
- appium/protocols/webdriver/can_find_elements.py,sha256=glM-Qpe-_KyLhZmojl6aa82B3xhEzRpJPyVQHhtOP8Q,1492
272
+ appium/protocols/webdriver/can_find_elements.py,sha256=_RwOaFcNzTOP0RDW-ejJXANxfSDU8p9SKXqm3eSXa3I,1246
273
273
  appium/webdriver/__init__.py,sha256=oT-lIYWpqD562rbXy36HlS03pKfW48BIxqZsqt1XEm0,730
274
274
  appium/webdriver/appium_connection.py,sha256=qh6LowDI9_6gwPxy50LGD96YTqKwa0ODGM1RUGOSpks,2580
275
275
  appium/webdriver/appium_service.py,sha256=kpb_AkoA_6jAupLFgVRJ7QP-98U8NAxbkw5qGmqqMQM,13003
@@ -281,11 +281,11 @@ appium/webdriver/connectiontype.py,sha256=ZDiibECp-bdFkWy2_PRrJboi0bf-QQDWNsnpra
281
281
  appium/webdriver/errorhandler.py,sha256=_aT6Qo64ARGch7evG2Uku4-l8wkDaM1R2o06PWXxwr8,5640
282
282
  appium/webdriver/locator_converter.py,sha256=uUdJsX1o0E8x-StcJvO5gFFJbcRzhOmySfgPqJ0UaU4,999
283
283
  appium/webdriver/mobilecommand.py,sha256=B_okscraJMPrN4hSyetSNddkOZ0PyTzsQvBdYHHQqvM,3162
284
- appium/webdriver/switch_to.py,sha256=kom9MHNOdZuEG0ALDuaw27NHvtsRDnl-sy_XNAd-Rl4,1174
285
- appium/webdriver/webdriver.py,sha256=6i3KPWyBOKeshv58VB9N0vDFTgDmU6z9oEpup3cSyjo,19328
286
- appium/webdriver/webelement.py,sha256=ewBkxaZiJtmhRoKjQk317WjewansQ6tpm3JePSv1pQ4,4500
284
+ appium/webdriver/switch_to.py,sha256=px12JwzTXngGWJiOfKXKaIc_QOoB1144Dv2U19jebSo,1386
285
+ appium/webdriver/webdriver.py,sha256=TOU7WYEyXSYJWwraIC4_L3-W79Paen9GGrWYYWtJrIA,19936
286
+ appium/webdriver/webelement.py,sha256=P7ev_K9DwmMJ8oS6u4TpLi7R5xFcsSE8dmu2ICfrvJA,4472
287
287
  appium/webdriver/common/__init__.py,sha256=4MapoJ3p5LiP0AsHMgL2xoPTIFno4dcH1GSoxaZzv4w,623
288
- appium/webdriver/common/appiumby.py,sha256=1sFzgJht8v9pO0fG-uK1jgbb8zMJwfBy3LJH15OPqq8,1785
288
+ appium/webdriver/common/appiumby.py,sha256=cO3RpM41ht9kPzgLFvKwBLhVv832WjOsnuP0vEqvAeY,1896
289
289
  appium/webdriver/extensions/__init__.py,sha256=wSUl6yC2TJNla7xbHXkCfn9J1LpQs9UIx8oOs6V8kZA,567
290
290
  appium/webdriver/extensions/action_helpers.py,sha256=yK_SDJCl-PeepC3C-zXJnfCLkcFwRz3NB_SH4JicFTw,9388
291
291
  appium/webdriver/extensions/applications.py,sha256=KnRD9-JilgYtBuy8dik2iGI5GeS2RPQws2BSdKL9HDo,6575
@@ -317,9 +317,9 @@ appium/webdriver/extensions/android/sms.py,sha256=ZXvZ0DpA_X5iojNDlh91O8tYJUmNb2
317
317
  appium/webdriver/extensions/android/system_bars.py,sha256=1vCIwg5UGpY1GfCoXFPL9nfSVjafAGVsTonBMrmIwaw,1530
318
318
  appium/webdriver/extensions/flutter_integration/__init__.py,sha256=wSUl6yC2TJNla7xbHXkCfn9J1LpQs9UIx8oOs6V8kZA,567
319
319
  appium/webdriver/extensions/flutter_integration/flutter_commands.py,sha256=1bAczDwqr40Rrbln321cIVG83ghar7-27aerRAKbfMs,12306
320
- appium/webdriver/extensions/flutter_integration/flutter_finder.py,sha256=HH9vGAouJuHzp29Jam_lQGrh67PDq6MxU5Ifewf7C5w,2164
320
+ appium/webdriver/extensions/flutter_integration/flutter_finder.py,sha256=fq3ORd4-PGUurJn0xLUMfqg7P9sE-Syv353brgcyGfM,2039
321
321
  appium/webdriver/extensions/flutter_integration/scroll_directions.py,sha256=y1BCEbWHJ86ivj5quhln10uwV9fWsA6nsdQ18j1Ua3E,123
322
- appium_python_client-6.1.4.dist-info/METADATA,sha256=PQUU3xirFx0Sll61PqYlPdj8LiByORgDMAKP5Y2pjj4,22042
323
- appium_python_client-6.1.4.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
324
- appium_python_client-6.1.4.dist-info/licenses/LICENSE,sha256=QxeKfXNmPWCfFyrXiwdVzMFPFMK0nlBrKhYLUoIcqhk,11384
325
- appium_python_client-6.1.4.dist-info/RECORD,,
322
+ appium_python_client-6.1.6.dist-info/METADATA,sha256=C3lWw-UC-gCA02DZjO60AgEb-4vyeQIuoU2DSDhT_rU,22201
323
+ appium_python_client-6.1.6.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
324
+ appium_python_client-6.1.6.dist-info/licenses/LICENSE,sha256=QxeKfXNmPWCfFyrXiwdVzMFPFMK0nlBrKhYLUoIcqhk,11384
325
+ appium_python_client-6.1.6.dist-info/RECORD,,