Appium-Python-Client 5.3.0__py3-none-any.whl → 6.0.0__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.
- appium/version.py +2 -7
- appium/webdriver/extensions/android/activities.py +7 -16
- appium/webdriver/extensions/android/common.py +3 -28
- appium/webdriver/extensions/android/display.py +4 -17
- appium/webdriver/extensions/android/gsm.py +4 -26
- appium/webdriver/extensions/android/network.py +33 -59
- appium/webdriver/extensions/android/performance.py +9 -30
- appium/webdriver/extensions/android/power.py +7 -22
- appium/webdriver/extensions/android/sms.py +4 -12
- appium/webdriver/extensions/android/system_bars.py +4 -17
- appium/webdriver/extensions/applications.py +48 -130
- appium/webdriver/extensions/clipboard.py +11 -27
- appium/webdriver/extensions/device_time.py +7 -27
- appium/webdriver/extensions/hw_actions.py +25 -52
- appium/webdriver/extensions/keyboard.py +27 -69
- appium/webdriver/extensions/location.py +1 -11
- appium/webdriver/extensions/remote_fs.py +20 -40
- appium/webdriver/mobilecommand.py +0 -4
- appium/webdriver/webdriver.py +2 -37
- {appium_python_client-5.3.0.dist-info → appium_python_client-6.0.0.dist-info}/METADATA +42 -48
- {appium_python_client-5.3.0.dist-info → appium_python_client-6.0.0.dist-info}/RECORD +23 -24
- {appium_python_client-5.3.0.dist-info → appium_python_client-6.0.0.dist-info}/WHEEL +1 -1
- appium/protocols/webdriver/can_remember_extension_presence.py +0 -23
- {appium_python_client-5.3.0.dist-info → appium_python_client-6.0.0.dist-info}/licenses/LICENSE +0 -0
appium/version.py
CHANGED
|
@@ -12,11 +12,6 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from importlib import
|
|
15
|
+
from importlib.metadata import version as _metadata_version
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
def _get_version():
|
|
19
|
-
return metadata.version('Appium-Python-Client')
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
version = _get_version()
|
|
17
|
+
version = _metadata_version('Appium-Python-Client')
|
|
@@ -12,35 +12,33 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from selenium.common.exceptions import TimeoutException
|
|
15
|
+
from selenium.common.exceptions import TimeoutException
|
|
16
16
|
from selenium.webdriver.support.ui import WebDriverWait
|
|
17
17
|
|
|
18
18
|
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
|
|
19
19
|
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
|
|
20
|
-
from appium.protocols.webdriver.can_remember_extension_presence import CanRememberExtensionPresence
|
|
21
|
-
from appium.webdriver.mobilecommand import MobileCommand as Command
|
|
22
20
|
|
|
23
21
|
|
|
24
|
-
class Activities(CanExecuteCommands, CanExecuteScripts
|
|
22
|
+
class Activities(CanExecuteCommands, CanExecuteScripts):
|
|
25
23
|
@property
|
|
26
24
|
def current_activity(self) -> str:
|
|
27
25
|
"""Retrieves the current activity running on the device.
|
|
28
26
|
|
|
27
|
+
Requires the Appium driver to support the `mobile: getCurrentActivity` execute method.
|
|
28
|
+
|
|
29
29
|
Returns:
|
|
30
30
|
str: The current activity name running on the device
|
|
31
31
|
"""
|
|
32
32
|
ext_name = 'mobile: getCurrentActivity'
|
|
33
|
-
|
|
34
|
-
return self.assert_extension_exists(ext_name).execute_script(ext_name)
|
|
35
|
-
except UnknownMethodException:
|
|
36
|
-
# TODO: Remove the fallback
|
|
37
|
-
return self.mark_extension_absence(ext_name).execute(Command.GET_CURRENT_ACTIVITY)['value']
|
|
33
|
+
return self.execute_script(ext_name)
|
|
38
34
|
|
|
39
35
|
def wait_activity(self, activity: str, timeout: int, interval: int = 1) -> bool:
|
|
40
36
|
"""Wait for an activity: block until target activity presents or time out.
|
|
41
37
|
|
|
42
38
|
This is an Android-only method.
|
|
43
39
|
|
|
40
|
+
Requires the Appium driver to support the `mobile: getCurrentActivity` execute method.
|
|
41
|
+
|
|
44
42
|
Args:
|
|
45
43
|
activity: target activity
|
|
46
44
|
timeout: max wait time, in seconds
|
|
@@ -56,10 +54,3 @@ class Activities(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPres
|
|
|
56
54
|
return True
|
|
57
55
|
except TimeoutException:
|
|
58
56
|
return False
|
|
59
|
-
|
|
60
|
-
def _add_commands(self) -> None:
|
|
61
|
-
self.command_executor.add_command(
|
|
62
|
-
Command.GET_CURRENT_ACTIVITY,
|
|
63
|
-
'GET',
|
|
64
|
-
'/session/$sessionId/appium/device/current_activity',
|
|
65
|
-
)
|
|
@@ -12,48 +12,23 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from selenium.common.exceptions import UnknownMethodException
|
|
16
15
|
from typing_extensions import Self
|
|
17
16
|
|
|
18
17
|
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
|
|
19
18
|
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
|
|
20
|
-
from appium.protocols.webdriver.can_remember_extension_presence import CanRememberExtensionPresence
|
|
21
|
-
from appium.webdriver.mobilecommand import MobileCommand as Command
|
|
22
19
|
|
|
23
20
|
|
|
24
|
-
class Common(CanExecuteCommands, CanExecuteScripts
|
|
21
|
+
class Common(CanExecuteCommands, CanExecuteScripts):
|
|
25
22
|
def open_notifications(self) -> Self:
|
|
26
23
|
"""Open notification shade in Android (API Level 18 and above)
|
|
27
24
|
|
|
28
25
|
Returns:
|
|
29
26
|
Union['WebDriver', 'Common']: Self instance
|
|
30
27
|
"""
|
|
31
|
-
|
|
32
|
-
try:
|
|
33
|
-
self.assert_extension_exists(ext_name).execute_script(ext_name)
|
|
34
|
-
except UnknownMethodException:
|
|
35
|
-
# TODO: Remove the fallback
|
|
36
|
-
self.mark_extension_absence(ext_name).execute(Command.OPEN_NOTIFICATIONS, {})
|
|
28
|
+
self.execute_script('mobile: openNotifications')
|
|
37
29
|
return self
|
|
38
30
|
|
|
39
31
|
@property
|
|
40
32
|
def current_package(self) -> str:
|
|
41
33
|
"""Retrieves the current package running on the device."""
|
|
42
|
-
|
|
43
|
-
try:
|
|
44
|
-
return self.assert_extension_exists(ext_name).execute_script(ext_name)
|
|
45
|
-
except UnknownMethodException:
|
|
46
|
-
# TODO: Remove the fallback
|
|
47
|
-
return self.mark_extension_absence(ext_name).execute(Command.GET_CURRENT_PACKAGE)['value']
|
|
48
|
-
|
|
49
|
-
def _add_commands(self) -> None:
|
|
50
|
-
self.command_executor.add_command(
|
|
51
|
-
Command.GET_CURRENT_PACKAGE,
|
|
52
|
-
'GET',
|
|
53
|
-
'/session/$sessionId/appium/device/current_package',
|
|
54
|
-
)
|
|
55
|
-
self.command_executor.add_command(
|
|
56
|
-
Command.OPEN_NOTIFICATIONS,
|
|
57
|
-
'POST',
|
|
58
|
-
'/session/$sessionId/appium/device/open_notifications',
|
|
59
|
-
)
|
|
34
|
+
return self.execute_script('mobile: getCurrentPackage')
|
|
@@ -12,18 +12,16 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from selenium.common.exceptions import UnknownMethodException
|
|
16
|
-
|
|
17
15
|
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
|
|
18
16
|
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
|
|
19
|
-
from appium.protocols.webdriver.can_remember_extension_presence import CanRememberExtensionPresence
|
|
20
|
-
from appium.webdriver.mobilecommand import MobileCommand as Command
|
|
21
17
|
|
|
22
18
|
|
|
23
|
-
class Display(CanExecuteCommands, CanExecuteScripts
|
|
19
|
+
class Display(CanExecuteCommands, CanExecuteScripts):
|
|
24
20
|
def get_display_density(self) -> int:
|
|
25
21
|
"""Get the display density, Android only
|
|
26
22
|
|
|
23
|
+
Requires the Appium driver to support the `mobile: getDisplayDensity` execute method.
|
|
24
|
+
|
|
27
25
|
Returns:
|
|
28
26
|
The display density of the Android device(dpi)
|
|
29
27
|
|
|
@@ -34,15 +32,4 @@ class Display(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresenc
|
|
|
34
32
|
int: The display density
|
|
35
33
|
"""
|
|
36
34
|
ext_name = 'mobile: getDisplayDensity'
|
|
37
|
-
|
|
38
|
-
return self.assert_extension_exists(ext_name).execute_script(ext_name)
|
|
39
|
-
except UnknownMethodException:
|
|
40
|
-
# TODO: Remove the fallback
|
|
41
|
-
return self.mark_extension_absence(ext_name).execute(Command.GET_DISPLAY_DENSITY)['value']
|
|
42
|
-
|
|
43
|
-
def _add_commands(self) -> None:
|
|
44
|
-
self.command_executor.add_command(
|
|
45
|
-
Command.GET_DISPLAY_DENSITY,
|
|
46
|
-
'GET',
|
|
47
|
-
'/session/$sessionId/appium/device/display_density',
|
|
48
|
-
)
|
|
35
|
+
return self.execute_script(ext_name)
|
|
@@ -12,15 +12,12 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from selenium.common.exceptions import UnknownMethodException
|
|
16
15
|
from typing_extensions import Self
|
|
17
16
|
|
|
18
17
|
from appium.common.helper import extract_const_attributes
|
|
19
18
|
from appium.common.logger import logger
|
|
20
19
|
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
|
|
21
20
|
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
|
|
22
|
-
from appium.protocols.webdriver.can_remember_extension_presence import CanRememberExtensionPresence
|
|
23
|
-
from appium.webdriver.mobilecommand import MobileCommand as Command
|
|
24
21
|
|
|
25
22
|
|
|
26
23
|
class GsmCallActions:
|
|
@@ -48,7 +45,7 @@ class GsmVoiceState:
|
|
|
48
45
|
ON = 'on'
|
|
49
46
|
|
|
50
47
|
|
|
51
|
-
class Gsm(CanExecuteCommands, CanExecuteScripts
|
|
48
|
+
class Gsm(CanExecuteCommands, CanExecuteScripts):
|
|
52
49
|
def make_gsm_call(self, phone_number: str, action: str) -> Self:
|
|
53
50
|
"""Make GSM call (Emulator only)
|
|
54
51
|
|
|
@@ -73,11 +70,7 @@ class Gsm(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence):
|
|
|
73
70
|
f'(e.g. {GsmCallActions.__name__}.CALL)'
|
|
74
71
|
)
|
|
75
72
|
args = {'phoneNumber': phone_number, 'action': action}
|
|
76
|
-
|
|
77
|
-
self.assert_extension_exists(ext_name).execute_script(ext_name, args)
|
|
78
|
-
except UnknownMethodException:
|
|
79
|
-
# TODO: Remove the fallback
|
|
80
|
-
self.mark_extension_absence(ext_name).execute(Command.MAKE_GSM_CALL, args)
|
|
73
|
+
self.execute_script(ext_name, args)
|
|
81
74
|
return self
|
|
82
75
|
|
|
83
76
|
def set_gsm_signal(self, strength: int) -> Self:
|
|
@@ -102,13 +95,7 @@ class Gsm(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence):
|
|
|
102
95
|
f'{strength} is out of range. Consider using one of {list(constants.keys())} constants. '
|
|
103
96
|
f'(e.g. {GsmSignalStrength.__name__}.GOOD)'
|
|
104
97
|
)
|
|
105
|
-
|
|
106
|
-
self.assert_extension_exists(ext_name).execute_script(ext_name, {'strength': strength})
|
|
107
|
-
except UnknownMethodException:
|
|
108
|
-
# TODO: Remove the fallback
|
|
109
|
-
self.mark_extension_absence(ext_name).execute(
|
|
110
|
-
Command.SET_GSM_SIGNAL, {'signalStrength': strength, 'signalStrengh': strength}
|
|
111
|
-
)
|
|
98
|
+
self.execute_script(ext_name, {'strength': strength})
|
|
112
99
|
return self
|
|
113
100
|
|
|
114
101
|
def set_gsm_voice(self, state: str) -> Self:
|
|
@@ -134,14 +121,5 @@ class Gsm(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence):
|
|
|
134
121
|
f'(e.g. {GsmVoiceState.__name__}.HOME)'
|
|
135
122
|
)
|
|
136
123
|
args = {'state': state}
|
|
137
|
-
|
|
138
|
-
self.assert_extension_exists(ext_name).execute_script(ext_name, args)
|
|
139
|
-
except UnknownMethodException:
|
|
140
|
-
# TODO: Remove the fallback
|
|
141
|
-
self.mark_extension_absence(ext_name).execute(Command.SET_GSM_VOICE, args)
|
|
124
|
+
self.execute_script(ext_name, args)
|
|
142
125
|
return self
|
|
143
|
-
|
|
144
|
-
def _add_commands(self) -> None:
|
|
145
|
-
self.command_executor.add_command(Command.MAKE_GSM_CALL, 'POST', '/session/$sessionId/appium/device/gsm_call')
|
|
146
|
-
self.command_executor.add_command(Command.SET_GSM_SIGNAL, 'POST', '/session/$sessionId/appium/device/gsm_signal')
|
|
147
|
-
self.command_executor.add_command(Command.SET_GSM_VOICE, 'POST', '/session/$sessionId/appium/device/gsm_voice')
|
|
@@ -12,15 +12,12 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from selenium.common.exceptions import UnknownMethodException
|
|
16
15
|
from typing_extensions import Self
|
|
17
16
|
|
|
18
17
|
from appium.common.helper import extract_const_attributes
|
|
19
18
|
from appium.common.logger import logger
|
|
20
19
|
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
|
|
21
20
|
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
|
|
22
|
-
from appium.protocols.webdriver.can_remember_extension_presence import CanRememberExtensionPresence
|
|
23
|
-
from appium.webdriver.mobilecommand import MobileCommand as Command
|
|
24
21
|
|
|
25
22
|
|
|
26
23
|
class NetSpeed:
|
|
@@ -41,7 +38,7 @@ class NetworkMask:
|
|
|
41
38
|
AIRPLANE_MODE = 0b001
|
|
42
39
|
|
|
43
40
|
|
|
44
|
-
class Network(CanExecuteCommands, CanExecuteScripts
|
|
41
|
+
class Network(CanExecuteCommands, CanExecuteScripts):
|
|
45
42
|
@property
|
|
46
43
|
def network_connection(self) -> int:
|
|
47
44
|
"""Returns an integer bitmask specifying the network connection type.
|
|
@@ -51,18 +48,19 @@ class Network(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresenc
|
|
|
51
48
|
|
|
52
49
|
This API only works reliably on emulators (any version) and real devices
|
|
53
50
|
since API level 31.
|
|
51
|
+
|
|
52
|
+
Requires the Appium driver to support the `mobile: getConnectivity` execute method.
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
The current network connection bitmask
|
|
54
56
|
"""
|
|
55
57
|
ext_name = 'mobile: getConnectivity'
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
)
|
|
63
|
-
except UnknownMethodException:
|
|
64
|
-
# TODO: Remove the fallback
|
|
65
|
-
return self.mark_extension_absence(ext_name).execute(Command.GET_NETWORK_CONNECTION, {})['value']
|
|
58
|
+
result_map = self.execute_script(ext_name)
|
|
59
|
+
return (
|
|
60
|
+
(NetworkMask.WIFI if result_map['wifi'] else 0)
|
|
61
|
+
| (NetworkMask.DATA if result_map['data'] else 0)
|
|
62
|
+
| (NetworkMask.AIRPLANE_MODE if result_map['airplaneMode'] else 0)
|
|
63
|
+
)
|
|
66
64
|
|
|
67
65
|
def set_network_connection(self, connection_type: int) -> int:
|
|
68
66
|
"""Sets the network connection type. Android only.
|
|
@@ -88,43 +86,39 @@ class Network(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresenc
|
|
|
88
86
|
This API only works reliably on emulators (any version) and real devices
|
|
89
87
|
since API level 31.
|
|
90
88
|
|
|
89
|
+
Requires the Appium driver to support the `mobile: setConnectivity` and
|
|
90
|
+
`mobile: getConnectivity` execute methods.
|
|
91
|
+
|
|
91
92
|
Args:
|
|
92
93
|
connection_type: a member of the enum `appium.webdriver.ConnectionType`
|
|
93
94
|
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
Returns:
|
|
96
|
+
The current network connection bitmask after applying the change
|
|
96
97
|
"""
|
|
97
98
|
ext_name = 'mobile: setConnectivity'
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
except UnknownMethodException:
|
|
108
|
-
# TODO: Remove the fallback
|
|
109
|
-
return self.mark_extension_absence(ext_name).execute(
|
|
110
|
-
Command.SET_NETWORK_CONNECTION, {'parameters': {'type': connection_type}}
|
|
111
|
-
)['value']
|
|
99
|
+
self.execute_script(
|
|
100
|
+
ext_name,
|
|
101
|
+
{
|
|
102
|
+
'wifi': bool(connection_type & NetworkMask.WIFI),
|
|
103
|
+
'data': bool(connection_type & NetworkMask.DATA),
|
|
104
|
+
'airplaneMode': bool(connection_type & NetworkMask.AIRPLANE_MODE),
|
|
105
|
+
},
|
|
106
|
+
)
|
|
107
|
+
return self.network_connection
|
|
112
108
|
|
|
113
109
|
def toggle_wifi(self) -> Self:
|
|
114
110
|
"""Toggle the wifi on the device, Android only.
|
|
115
111
|
This API only works reliably on emulators (any version) and real devices
|
|
116
112
|
since API level 31.
|
|
117
113
|
|
|
114
|
+
Requires the Appium driver to support the `mobile: getConnectivity` and
|
|
115
|
+
`mobile: setConnectivity` execute methods.
|
|
116
|
+
|
|
118
117
|
Returns:
|
|
119
118
|
Union['WebDriver', 'Network']: Self instance
|
|
120
119
|
"""
|
|
121
120
|
ext_name = 'mobile: setConnectivity'
|
|
122
|
-
|
|
123
|
-
self.assert_extension_exists(ext_name).execute_script(
|
|
124
|
-
ext_name, {'wifi': not (self.network_connection & NetworkMask.WIFI)}
|
|
125
|
-
)
|
|
126
|
-
except UnknownMethodException:
|
|
127
|
-
self.mark_extension_absence(ext_name).execute(Command.TOGGLE_WIFI, {})
|
|
121
|
+
self.execute_script(ext_name, {'wifi': not (self.network_connection & NetworkMask.WIFI)})
|
|
128
122
|
return self
|
|
129
123
|
|
|
130
124
|
def set_network_speed(self, speed_type: str) -> Self:
|
|
@@ -132,6 +126,8 @@ class Network(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresenc
|
|
|
132
126
|
|
|
133
127
|
Android Emulator only.
|
|
134
128
|
|
|
129
|
+
Requires the Appium driver to support the `mobile: networkSpeed` execute method.
|
|
130
|
+
|
|
135
131
|
Args:
|
|
136
132
|
speed_type: The network speed type.
|
|
137
133
|
A member of the const appium.webdriver.extensions.android.network.NetSpeed.
|
|
@@ -149,27 +145,5 @@ class Network(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresenc
|
|
|
149
145
|
f'(e.g. {NetSpeed.__name__}.LTE)'
|
|
150
146
|
)
|
|
151
147
|
ext_name = 'mobile: networkSpeed'
|
|
152
|
-
|
|
153
|
-
self.assert_extension_exists(ext_name).execute_script(ext_name, {'speed': speed_type})
|
|
154
|
-
except UnknownMethodException:
|
|
155
|
-
# TODO: Remove the fallback
|
|
156
|
-
self.mark_extension_absence(ext_name).execute(Command.SET_NETWORK_SPEED, {'netspeed': speed_type})
|
|
148
|
+
self.execute_script(ext_name, {'speed': speed_type})
|
|
157
149
|
return self
|
|
158
|
-
|
|
159
|
-
def _add_commands(self) -> None:
|
|
160
|
-
self.command_executor.add_command(Command.TOGGLE_WIFI, 'POST', '/session/$sessionId/appium/device/toggle_wifi')
|
|
161
|
-
self.command_executor.add_command(
|
|
162
|
-
Command.GET_NETWORK_CONNECTION,
|
|
163
|
-
'GET',
|
|
164
|
-
'/session/$sessionId/network_connection',
|
|
165
|
-
)
|
|
166
|
-
self.command_executor.add_command(
|
|
167
|
-
Command.SET_NETWORK_CONNECTION,
|
|
168
|
-
'POST',
|
|
169
|
-
'/session/$sessionId/network_connection',
|
|
170
|
-
)
|
|
171
|
-
self.command_executor.add_command(
|
|
172
|
-
Command.SET_NETWORK_SPEED,
|
|
173
|
-
'POST',
|
|
174
|
-
'/session/$sessionId/appium/device/network_speed',
|
|
175
|
-
)
|
|
@@ -14,15 +14,11 @@
|
|
|
14
14
|
|
|
15
15
|
from typing import Dict, List, Union
|
|
16
16
|
|
|
17
|
-
from selenium.common.exceptions import UnknownMethodException
|
|
18
|
-
|
|
19
17
|
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
|
|
20
18
|
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
|
|
21
|
-
from appium.protocols.webdriver.can_remember_extension_presence import CanRememberExtensionPresence
|
|
22
|
-
from appium.webdriver.mobilecommand import MobileCommand as Command
|
|
23
19
|
|
|
24
20
|
|
|
25
|
-
class Performance(CanExecuteCommands, CanExecuteScripts
|
|
21
|
+
class Performance(CanExecuteCommands, CanExecuteScripts):
|
|
26
22
|
def get_performance_data(
|
|
27
23
|
self, package_name: str, data_type: str, data_read_timeout: Union[int, None] = None
|
|
28
24
|
) -> List[List[str]]:
|
|
@@ -31,12 +27,15 @@ class Performance(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPre
|
|
|
31
27
|
|
|
32
28
|
Android only.
|
|
33
29
|
|
|
30
|
+
Requires the Appium driver to support the `mobile: getPerformanceData` execute method.
|
|
31
|
+
|
|
34
32
|
Args:
|
|
35
33
|
package_name: The package name of the application
|
|
36
34
|
data_type: The type of system state which wants to read.
|
|
37
35
|
It should be one of the supported performance data types.
|
|
38
36
|
Check :func:`.get_performance_data_types` for supported types
|
|
39
|
-
data_read_timeout:
|
|
37
|
+
data_read_timeout: Legacy parameter retained for compatibility; ignored by
|
|
38
|
+
`mobile: getPerformanceData`
|
|
40
39
|
|
|
41
40
|
Usage:
|
|
42
41
|
self.driver.get_performance_data('my.app.package', 'cpuinfo', 5)
|
|
@@ -46,19 +45,15 @@ class Performance(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPre
|
|
|
46
45
|
"""
|
|
47
46
|
ext_name = 'mobile: getPerformanceData'
|
|
48
47
|
args: Dict[str, Union[str, int]] = {'packageName': package_name, 'dataType': data_type}
|
|
49
|
-
|
|
50
|
-
return self.assert_extension_exists(ext_name).execute_script(ext_name, args)
|
|
51
|
-
except UnknownMethodException:
|
|
52
|
-
# TODO: Remove the fallback
|
|
53
|
-
if data_read_timeout is not None:
|
|
54
|
-
args['dataReadTimeout'] = data_read_timeout
|
|
55
|
-
return self.mark_extension_absence(ext_name).execute(Command.GET_PERFORMANCE_DATA, args)['value']
|
|
48
|
+
return self.execute_script(ext_name, args)
|
|
56
49
|
|
|
57
50
|
def get_performance_data_types(self) -> List[str]:
|
|
58
51
|
"""Returns the information types of the system state
|
|
59
52
|
which is supported to read as like cpu, memory, network traffic, and battery.
|
|
60
53
|
Android only.
|
|
61
54
|
|
|
55
|
+
Requires the Appium driver to support the `mobile: getPerformanceDataTypes` execute method.
|
|
56
|
+
|
|
62
57
|
Usage:
|
|
63
58
|
self.driver.get_performance_data_types()
|
|
64
59
|
|
|
@@ -66,20 +61,4 @@ class Performance(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPre
|
|
|
66
61
|
Available data types
|
|
67
62
|
"""
|
|
68
63
|
ext_name = 'mobile: getPerformanceDataTypes'
|
|
69
|
-
|
|
70
|
-
return self.assert_extension_exists(ext_name).execute_script(ext_name)
|
|
71
|
-
except UnknownMethodException:
|
|
72
|
-
# TODO: Remove the fallback
|
|
73
|
-
return self.mark_extension_absence(ext_name).execute(Command.GET_PERFORMANCE_DATA_TYPES)['value']
|
|
74
|
-
|
|
75
|
-
def _add_commands(self) -> None:
|
|
76
|
-
self.command_executor.add_command(
|
|
77
|
-
Command.GET_PERFORMANCE_DATA,
|
|
78
|
-
'POST',
|
|
79
|
-
'/session/$sessionId/appium/getPerformanceData',
|
|
80
|
-
)
|
|
81
|
-
self.command_executor.add_command(
|
|
82
|
-
Command.GET_PERFORMANCE_DATA_TYPES,
|
|
83
|
-
'POST',
|
|
84
|
-
'/session/$sessionId/appium/performanceData/types',
|
|
85
|
-
)
|
|
64
|
+
return self.execute_script(ext_name)
|
|
@@ -12,16 +12,13 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from selenium.common.exceptions import UnknownMethodException
|
|
16
15
|
from typing_extensions import Self
|
|
17
16
|
|
|
18
17
|
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
|
|
19
18
|
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
|
|
20
|
-
from appium.protocols.webdriver.can_remember_extension_presence import CanRememberExtensionPresence
|
|
21
|
-
from appium.webdriver.mobilecommand import MobileCommand as Command
|
|
22
19
|
|
|
23
20
|
|
|
24
|
-
class Power(CanExecuteCommands, CanExecuteScripts
|
|
21
|
+
class Power(CanExecuteCommands, CanExecuteScripts):
|
|
25
22
|
AC_OFF, AC_ON = 'off', 'on'
|
|
26
23
|
|
|
27
24
|
def set_power_capacity(self, percent: int) -> Self:
|
|
@@ -29,6 +26,8 @@ class Power(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence)
|
|
|
29
26
|
|
|
30
27
|
Android only.
|
|
31
28
|
|
|
29
|
+
Requires the Appium driver to support the `mobile: powerCapacity` execute method.
|
|
30
|
+
|
|
32
31
|
Args:
|
|
33
32
|
percent: The power capacity to be set. Can be set from 0 to 100
|
|
34
33
|
|
|
@@ -40,11 +39,7 @@ class Power(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence)
|
|
|
40
39
|
"""
|
|
41
40
|
ext_name = 'mobile: powerCapacity'
|
|
42
41
|
args = {'percent': percent}
|
|
43
|
-
|
|
44
|
-
self.assert_extension_exists(ext_name).execute_script(ext_name, args)
|
|
45
|
-
except UnknownMethodException:
|
|
46
|
-
# TODO: Remove the fallback
|
|
47
|
-
self.mark_extension_absence(ext_name).execute(Command.SET_POWER_CAPACITY, args)
|
|
42
|
+
self.execute_script(ext_name, args)
|
|
48
43
|
return self
|
|
49
44
|
|
|
50
45
|
def set_power_ac(self, ac_state: str) -> Self:
|
|
@@ -52,6 +47,8 @@ class Power(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence)
|
|
|
52
47
|
|
|
53
48
|
Android only.
|
|
54
49
|
|
|
50
|
+
Requires the Appium driver to support the `mobile: powerAC` execute method.
|
|
51
|
+
|
|
55
52
|
Args:
|
|
56
53
|
ac_state: The power ac state to be set. Use `Power.AC_OFF`, `Power.AC_ON`
|
|
57
54
|
|
|
@@ -64,17 +61,5 @@ class Power(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence)
|
|
|
64
61
|
"""
|
|
65
62
|
ext_name = 'mobile: powerAC'
|
|
66
63
|
args = {'state': ac_state}
|
|
67
|
-
|
|
68
|
-
self.assert_extension_exists(ext_name).execute_script(ext_name, args)
|
|
69
|
-
except UnknownMethodException:
|
|
70
|
-
# TODO: Remove the fallback
|
|
71
|
-
self.mark_extension_absence(ext_name).execute(Command.SET_POWER_AC, args)
|
|
64
|
+
self.execute_script(ext_name, args)
|
|
72
65
|
return self
|
|
73
|
-
|
|
74
|
-
def _add_commands(self) -> None:
|
|
75
|
-
self.command_executor.add_command(
|
|
76
|
-
Command.SET_POWER_CAPACITY,
|
|
77
|
-
'POST',
|
|
78
|
-
'/session/$sessionId/appium/device/power_capacity',
|
|
79
|
-
)
|
|
80
|
-
self.command_executor.add_command(Command.SET_POWER_AC, 'POST', '/session/$sessionId/appium/device/power_ac')
|
|
@@ -12,21 +12,20 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from selenium.common.exceptions import UnknownMethodException
|
|
16
15
|
from typing_extensions import Self
|
|
17
16
|
|
|
18
17
|
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
|
|
19
18
|
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
|
|
20
|
-
from appium.protocols.webdriver.can_remember_extension_presence import CanRememberExtensionPresence
|
|
21
|
-
from appium.webdriver.mobilecommand import MobileCommand as Command
|
|
22
19
|
|
|
23
20
|
|
|
24
|
-
class Sms(CanExecuteCommands, CanExecuteScripts
|
|
21
|
+
class Sms(CanExecuteCommands, CanExecuteScripts):
|
|
25
22
|
def send_sms(self, phone_number: str, message: str) -> Self:
|
|
26
23
|
"""Emulate send SMS event on the connected emulator.
|
|
27
24
|
|
|
28
25
|
Android only.
|
|
29
26
|
|
|
27
|
+
Requires the Appium driver to support the `mobile: sendSms` execute method.
|
|
28
|
+
|
|
30
29
|
Args:
|
|
31
30
|
phone_number: The phone number of message sender
|
|
32
31
|
message: The message to send
|
|
@@ -39,12 +38,5 @@ class Sms(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence):
|
|
|
39
38
|
"""
|
|
40
39
|
ext_name = 'mobile: sendSms'
|
|
41
40
|
args = {'phoneNumber': phone_number, 'message': message}
|
|
42
|
-
|
|
43
|
-
self.assert_extension_exists(ext_name).execute_script(ext_name, args)
|
|
44
|
-
except UnknownMethodException:
|
|
45
|
-
# TODO: Remove the fallback
|
|
46
|
-
self.mark_extension_absence(ext_name).execute(Command.SEND_SMS, args)
|
|
41
|
+
self.execute_script(ext_name, args)
|
|
47
42
|
return self
|
|
48
|
-
|
|
49
|
-
def _add_commands(self) -> None:
|
|
50
|
-
self.command_executor.add_command(Command.SEND_SMS, 'POST', '/session/$sessionId/appium/device/send_sms')
|
|
@@ -14,20 +14,18 @@
|
|
|
14
14
|
|
|
15
15
|
from typing import Dict, Union
|
|
16
16
|
|
|
17
|
-
from selenium.common.exceptions import UnknownMethodException
|
|
18
|
-
|
|
19
17
|
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
|
|
20
18
|
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
|
|
21
|
-
from appium.protocols.webdriver.can_remember_extension_presence import CanRememberExtensionPresence
|
|
22
|
-
from appium.webdriver.mobilecommand import MobileCommand as Command
|
|
23
19
|
|
|
24
20
|
|
|
25
|
-
class SystemBars(CanExecuteCommands, CanExecuteScripts
|
|
21
|
+
class SystemBars(CanExecuteCommands, CanExecuteScripts):
|
|
26
22
|
def get_system_bars(self) -> Dict[str, Dict[str, Union[int, bool]]]:
|
|
27
23
|
"""Retrieve visibility and bounds information of the status and navigation bars.
|
|
28
24
|
|
|
29
25
|
Android only.
|
|
30
26
|
|
|
27
|
+
Requires the Appium driver to support the `mobile: getSystemBars` execute method.
|
|
28
|
+
|
|
31
29
|
Returns:
|
|
32
30
|
A dictionary whose keys are
|
|
33
31
|
- statusBar
|
|
@@ -44,15 +42,4 @@ class SystemBars(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPres
|
|
|
44
42
|
- height
|
|
45
43
|
"""
|
|
46
44
|
ext_name = 'mobile: getSystemBars'
|
|
47
|
-
|
|
48
|
-
return self.assert_extension_exists(ext_name).execute_script(ext_name)
|
|
49
|
-
except UnknownMethodException:
|
|
50
|
-
# TODO: Remove the fallback
|
|
51
|
-
return self.mark_extension_absence(ext_name).execute(Command.GET_SYSTEM_BARS)['value']
|
|
52
|
-
|
|
53
|
-
def _add_commands(self) -> None:
|
|
54
|
-
self.command_executor.add_command(
|
|
55
|
-
Command.GET_SYSTEM_BARS,
|
|
56
|
-
'GET',
|
|
57
|
-
'/session/$sessionId/appium/device/system_bars',
|
|
58
|
-
)
|
|
45
|
+
return self.execute_script(ext_name)
|