pumapy 2.2.0__tar.gz → 2.3.0__tar.gz
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.
- {pumapy-2.2.0/pumapy.egg-info → pumapy-2.3.0}/PKG-INFO +36 -14
- {pumapy-2.2.0 → pumapy-2.3.0}/README.md +35 -13
- {pumapy-2.2.0 → pumapy-2.3.0}/puma/apps/android/telegram/telegram.py +26 -13
- pumapy-2.3.0/puma/computer_vision/__init__.py +3 -0
- pumapy-2.3.0/puma/version.py +1 -0
- {pumapy-2.2.0 → pumapy-2.3.0/pumapy.egg-info}/PKG-INFO +36 -14
- {pumapy-2.2.0 → pumapy-2.3.0}/pumapy.egg-info/SOURCES.txt +2 -1
- pumapy-2.3.0/test/test_version.py +44 -0
- pumapy-2.2.0/puma/apps/android/whatsapp/__init__.py +0 -0
- pumapy-2.2.0/puma/version.py +0 -1
- {pumapy-2.2.0 → pumapy-2.3.0}/LICENSE.txt +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/puma/__init__.py +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/puma/apps/__init__.py +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/puma/apps/android/__init__.py +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/puma/apps/android/appium_actions.py +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/puma/apps/android/google_maps/__init__.py +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/puma/apps/android/google_maps/google_maps.py +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/puma/apps/android/snapchat/__init__.py +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/puma/apps/android/snapchat/snapchat.py +0 -0
- {pumapy-2.2.0/puma/computer_vision → pumapy-2.3.0/puma/apps/android/telegram}/__init__.py +0 -0
- {pumapy-2.2.0/puma/apps/android/telegram → pumapy-2.3.0/puma/apps/android/whatsapp}/__init__.py +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/puma/apps/android/whatsapp/whatsapp.py +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/puma/computer_vision/ocr.py +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/puma/utils/__init__.py +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/puma/utils/route_simulator.py +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/puma/utils/video_utils.py +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/pumapy.egg-info/dependency_links.txt +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/pumapy.egg-info/requires.txt +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/pumapy.egg-info/top_level.txt +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/setup.cfg +0 -0
- {pumapy-2.2.0 → pumapy-2.3.0}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pumapy
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Home-page: https://github.com/NetherlandsForensicInstitute/puma
|
|
5
5
|
Author: Netherlands Forensic Institute
|
|
6
6
|
Author-email: netherlandsforensicinstitute@users.noreply.github.com
|
|
@@ -20,7 +20,7 @@ Requires-Dist: requests~=2.32.3
|
|
|
20
20
|
|
|
21
21
|
# Puma - Programmable Utility for Mobile Automation
|
|
22
22
|
|
|
23
|
-
Puma is a Python library for executing app-specific actions on mobile devices such as sending a message or starting a
|
|
23
|
+
Puma is a Python library for executing app-specific actions on mobile devices such as sending a message or starting a
|
|
24
24
|
call. The goal is that you can focus on *what* should happen rather than *how* this should happen, so rather than write
|
|
25
25
|
code to "tap on Bob's conversation on Alice's phone, enter the message, and press send", you can simply write "send a
|
|
26
26
|
Telegram message to Bob from Alice's phone".
|
|
@@ -28,33 +28,48 @@ Telegram message to Bob from Alice's phone".
|
|
|
28
28
|
To execute actions on the mobile device, Puma uses [Appium](https://appium.io/), and open-source project for UI
|
|
29
29
|
automation.
|
|
30
30
|
|
|
31
|
-
Puma
|
|
32
|
-
|
|
31
|
+
Puma was created at the NFI to improve our process of creating test and reference datasets. Our best practices on
|
|
32
|
+
creating test data can be found [here](docs/TESTDATA_GUIDELINES.md). If you are wondering whether you should make your
|
|
33
|
+
own test data, or whether you should use Puma for it, [this document](docs/TESTDATA_WHY.md) goes into the advantages of
|
|
34
|
+
doing so.
|
|
35
|
+
|
|
36
|
+
Puma is an open-source non-commercial project, and community contributions to add support for apps, or improve support
|
|
37
|
+
of existing apps are welcome! If you want to contribute, please read [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
33
38
|
|
|
34
39
|
> :no_mobile_phones: Puma currently only supports Android apps. iOS apps are on our to-do list!
|
|
40
|
+
|
|
35
41
|
## Getting started
|
|
42
|
+
|
|
36
43
|
1. Install all required software (see the [requirements](#requirements) section).
|
|
37
44
|
- install [ADB](#ADB)
|
|
38
45
|
- install [Appium](#Appium)
|
|
39
|
-
2. Connect your Android device (or start an emulator), make sure it is connected properly over ADB (See the
|
|
40
|
-
[troubleshooting](#Troubleshooting) if you encounter problems).
|
|
46
|
+
2. Connect your Android device (or start an emulator), make sure it is connected properly over ADB (See the section on
|
|
47
|
+
[troubleshooting](#Troubleshooting) if you encounter problems).
|
|
41
48
|
- :warn: Make sure the phone is set to English, and [all other requirements](#Android-Devices-or-Emulators) are met!
|
|
42
|
-
3. Get the UDID of your device by running `adb devices` (in the example below `954724ertyui74125` is the UDID of the
|
|
49
|
+
3. Get the UDID of your device by running `adb devices` (in the example below `954724ertyui74125` is the UDID of the
|
|
50
|
+
device):
|
|
51
|
+
|
|
43
52
|
```shell
|
|
44
53
|
$ adb devices
|
|
45
54
|
> List of devices attached
|
|
46
55
|
954724ertyui74125 device
|
|
47
56
|
```
|
|
57
|
+
|
|
48
58
|
4. Install Puma. We recommend always installing packages within [a Python venv](https://docs.python.org/3/library/venv.html).
|
|
59
|
+
|
|
49
60
|
```shell
|
|
50
61
|
pip install pumapy
|
|
51
62
|
```
|
|
63
|
+
|
|
52
64
|
5. Run Appium. This starts the Appium server, a process that needs to run while you use Puma.
|
|
65
|
+
|
|
53
66
|
```shell
|
|
54
67
|
appium
|
|
55
68
|
```
|
|
69
|
+
|
|
56
70
|
Now you can use Puma! The code below is a small example on how to send a WhatsApp message, you can run this on a phone
|
|
57
71
|
that has WhatsApp installed and has a registered WhatsApp account:
|
|
72
|
+
|
|
58
73
|
```python
|
|
59
74
|
from puma.apps.android.whatsapp.whatsapp import WhatsappActions
|
|
60
75
|
|
|
@@ -62,9 +77,11 @@ alice = WhatsappActions("<INSERT UDID HERE>") # Initialize a connection with de
|
|
|
62
77
|
alice.create_new_chat(contact="<Insert the contact name>", first_message="Hello world!") # Send a message to contact in your contact list
|
|
63
78
|
alice.send_message("Sorry for the spam :)") # we can send a second message in the open conversation
|
|
64
79
|
```
|
|
80
|
+
|
|
65
81
|
Congratulations, you just sent a WhatsApp message without touching your phone!
|
|
66
82
|
You can now explore what other function are possible with Puma in [WhatsApp](puma/apps/android/whatsapp/README.md), or
|
|
67
|
-
try a [different application](#supported-apps). Or you could even start working
|
|
83
|
+
try a [different application](#supported-apps). Or you could even start working
|
|
84
|
+
on [adding support for a new app](CONTRIBUTING.md).
|
|
68
85
|
|
|
69
86
|
## Supported apps
|
|
70
87
|
|
|
@@ -74,6 +91,7 @@ example implementations:
|
|
|
74
91
|
* [WhatsApp](puma/apps/android/whatsapp/README.md)
|
|
75
92
|
* [Telegram](puma/apps/android/telegram/README.md)
|
|
76
93
|
* [Snapchat](puma/apps/android/snapchat/README.md)
|
|
94
|
+
* [Google Maps](puma/apps/android/google_maps/README.md)
|
|
77
95
|
|
|
78
96
|
Right now only Android is supported.
|
|
79
97
|
|
|
@@ -94,11 +112,13 @@ to use an older release of Puma.
|
|
|
94
112
|
To make it easy for users to lookup older versions, git tags will be used to tag app versions. So in the above example
|
|
95
113
|
you'd simply have to look up the tag `Xyz_v2`.
|
|
96
114
|
|
|
97
|
-
If you are running your script on a newer app version
|
|
98
|
-
app (can be found in the [test scripts directory](test_scripts)). This test script includes each action that can be
|
|
99
|
-
you if all actions are still supported, without messing up
|
|
115
|
+
If you are running your script on a newer app version than the tag, it is advised to first run the test script of your
|
|
116
|
+
app (can be found in the [test scripts directory](test_scripts)). This test script includes each action that can be
|
|
117
|
+
performed on the phone, and running these first will inform you if all actions are still supported, without messing up
|
|
118
|
+
your experiment.
|
|
100
119
|
|
|
101
120
|
#### Navigation
|
|
121
|
+
|
|
102
122
|
You need to be careful about navigation. For example, some methods require you to already be in a conversation. However,
|
|
103
123
|
most methods give you the option to navigate to a specific conversation. 2 examples:
|
|
104
124
|
|
|
@@ -148,16 +168,18 @@ sudo apt install python3.11
|
|
|
148
168
|
|
|
149
169
|
Puma uses ADB to connect to Android devices for some features, both directly and through Appium.
|
|
150
170
|
To install ADB, download [the Android Sdk Platform Tools](https://developer.android.com/tools/releases/platform-tools).
|
|
151
|
-
Create the directory `~/Android/Sdk/` and unzip the platform-tools in this folder, so the absolute path to adb becomes
|
|
152
|
-
Then create the environmental value `ANDROID_SDK_ROOT` with the value
|
|
171
|
+
Create the directory `~/Android/Sdk/` and unzip the platform-tools in this folder, so the absolute path to adb becomes
|
|
172
|
+
`~/Android/Sdk/platform-tools/adb`. Then create the environmental value `ANDROID_SDK_ROOT` with the value
|
|
173
|
+
`~/Android/Sdk/`:
|
|
153
174
|
|
|
154
175
|
```shell
|
|
155
176
|
$ echo 'export ANDROID_SDK_ROOT="$HOME/Android/Sdk/"' >> ~/.bashrc
|
|
156
177
|
$ source ~/.bashrc
|
|
157
178
|
```
|
|
179
|
+
|
|
158
180
|
> :warning: When running your Appium script from an IDE, you might get the error `Could not determine ANDROID_SDK_ROOT.`
|
|
159
181
|
> This is because the IDE might not load the environment variables correctly. Since Puma then defaults to ~/Android/Sdk,
|
|
160
|
-
> you will not need to do anything if you followed the steps above, and you can ignore this message. If you really want
|
|
182
|
+
> you will not need to do anything if you followed the steps above, and you can ignore this message. If you really want
|
|
161
183
|
> to use another location, please refer to you IDE specific documentation how to set environment variables.
|
|
162
184
|
|
|
163
185
|
### Appium
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Puma - Programmable Utility for Mobile Automation
|
|
2
2
|
|
|
3
|
-
Puma is a Python library for executing app-specific actions on mobile devices such as sending a message or starting a
|
|
3
|
+
Puma is a Python library for executing app-specific actions on mobile devices such as sending a message or starting a
|
|
4
4
|
call. The goal is that you can focus on *what* should happen rather than *how* this should happen, so rather than write
|
|
5
5
|
code to "tap on Bob's conversation on Alice's phone, enter the message, and press send", you can simply write "send a
|
|
6
6
|
Telegram message to Bob from Alice's phone".
|
|
@@ -8,33 +8,48 @@ Telegram message to Bob from Alice's phone".
|
|
|
8
8
|
To execute actions on the mobile device, Puma uses [Appium](https://appium.io/), and open-source project for UI
|
|
9
9
|
automation.
|
|
10
10
|
|
|
11
|
-
Puma
|
|
12
|
-
|
|
11
|
+
Puma was created at the NFI to improve our process of creating test and reference datasets. Our best practices on
|
|
12
|
+
creating test data can be found [here](docs/TESTDATA_GUIDELINES.md). If you are wondering whether you should make your
|
|
13
|
+
own test data, or whether you should use Puma for it, [this document](docs/TESTDATA_WHY.md) goes into the advantages of
|
|
14
|
+
doing so.
|
|
15
|
+
|
|
16
|
+
Puma is an open-source non-commercial project, and community contributions to add support for apps, or improve support
|
|
17
|
+
of existing apps are welcome! If you want to contribute, please read [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
13
18
|
|
|
14
19
|
> :no_mobile_phones: Puma currently only supports Android apps. iOS apps are on our to-do list!
|
|
20
|
+
|
|
15
21
|
## Getting started
|
|
22
|
+
|
|
16
23
|
1. Install all required software (see the [requirements](#requirements) section).
|
|
17
24
|
- install [ADB](#ADB)
|
|
18
25
|
- install [Appium](#Appium)
|
|
19
|
-
2. Connect your Android device (or start an emulator), make sure it is connected properly over ADB (See the
|
|
20
|
-
[troubleshooting](#Troubleshooting) if you encounter problems).
|
|
26
|
+
2. Connect your Android device (or start an emulator), make sure it is connected properly over ADB (See the section on
|
|
27
|
+
[troubleshooting](#Troubleshooting) if you encounter problems).
|
|
21
28
|
- :warn: Make sure the phone is set to English, and [all other requirements](#Android-Devices-or-Emulators) are met!
|
|
22
|
-
3. Get the UDID of your device by running `adb devices` (in the example below `954724ertyui74125` is the UDID of the
|
|
29
|
+
3. Get the UDID of your device by running `adb devices` (in the example below `954724ertyui74125` is the UDID of the
|
|
30
|
+
device):
|
|
31
|
+
|
|
23
32
|
```shell
|
|
24
33
|
$ adb devices
|
|
25
34
|
> List of devices attached
|
|
26
35
|
954724ertyui74125 device
|
|
27
36
|
```
|
|
37
|
+
|
|
28
38
|
4. Install Puma. We recommend always installing packages within [a Python venv](https://docs.python.org/3/library/venv.html).
|
|
39
|
+
|
|
29
40
|
```shell
|
|
30
41
|
pip install pumapy
|
|
31
42
|
```
|
|
43
|
+
|
|
32
44
|
5. Run Appium. This starts the Appium server, a process that needs to run while you use Puma.
|
|
45
|
+
|
|
33
46
|
```shell
|
|
34
47
|
appium
|
|
35
48
|
```
|
|
49
|
+
|
|
36
50
|
Now you can use Puma! The code below is a small example on how to send a WhatsApp message, you can run this on a phone
|
|
37
51
|
that has WhatsApp installed and has a registered WhatsApp account:
|
|
52
|
+
|
|
38
53
|
```python
|
|
39
54
|
from puma.apps.android.whatsapp.whatsapp import WhatsappActions
|
|
40
55
|
|
|
@@ -42,9 +57,11 @@ alice = WhatsappActions("<INSERT UDID HERE>") # Initialize a connection with de
|
|
|
42
57
|
alice.create_new_chat(contact="<Insert the contact name>", first_message="Hello world!") # Send a message to contact in your contact list
|
|
43
58
|
alice.send_message("Sorry for the spam :)") # we can send a second message in the open conversation
|
|
44
59
|
```
|
|
60
|
+
|
|
45
61
|
Congratulations, you just sent a WhatsApp message without touching your phone!
|
|
46
62
|
You can now explore what other function are possible with Puma in [WhatsApp](puma/apps/android/whatsapp/README.md), or
|
|
47
|
-
try a [different application](#supported-apps). Or you could even start working
|
|
63
|
+
try a [different application](#supported-apps). Or you could even start working
|
|
64
|
+
on [adding support for a new app](CONTRIBUTING.md).
|
|
48
65
|
|
|
49
66
|
## Supported apps
|
|
50
67
|
|
|
@@ -54,6 +71,7 @@ example implementations:
|
|
|
54
71
|
* [WhatsApp](puma/apps/android/whatsapp/README.md)
|
|
55
72
|
* [Telegram](puma/apps/android/telegram/README.md)
|
|
56
73
|
* [Snapchat](puma/apps/android/snapchat/README.md)
|
|
74
|
+
* [Google Maps](puma/apps/android/google_maps/README.md)
|
|
57
75
|
|
|
58
76
|
Right now only Android is supported.
|
|
59
77
|
|
|
@@ -74,11 +92,13 @@ to use an older release of Puma.
|
|
|
74
92
|
To make it easy for users to lookup older versions, git tags will be used to tag app versions. So in the above example
|
|
75
93
|
you'd simply have to look up the tag `Xyz_v2`.
|
|
76
94
|
|
|
77
|
-
If you are running your script on a newer app version
|
|
78
|
-
app (can be found in the [test scripts directory](test_scripts)). This test script includes each action that can be
|
|
79
|
-
you if all actions are still supported, without messing up
|
|
95
|
+
If you are running your script on a newer app version than the tag, it is advised to first run the test script of your
|
|
96
|
+
app (can be found in the [test scripts directory](test_scripts)). This test script includes each action that can be
|
|
97
|
+
performed on the phone, and running these first will inform you if all actions are still supported, without messing up
|
|
98
|
+
your experiment.
|
|
80
99
|
|
|
81
100
|
#### Navigation
|
|
101
|
+
|
|
82
102
|
You need to be careful about navigation. For example, some methods require you to already be in a conversation. However,
|
|
83
103
|
most methods give you the option to navigate to a specific conversation. 2 examples:
|
|
84
104
|
|
|
@@ -128,16 +148,18 @@ sudo apt install python3.11
|
|
|
128
148
|
|
|
129
149
|
Puma uses ADB to connect to Android devices for some features, both directly and through Appium.
|
|
130
150
|
To install ADB, download [the Android Sdk Platform Tools](https://developer.android.com/tools/releases/platform-tools).
|
|
131
|
-
Create the directory `~/Android/Sdk/` and unzip the platform-tools in this folder, so the absolute path to adb becomes
|
|
132
|
-
Then create the environmental value `ANDROID_SDK_ROOT` with the value
|
|
151
|
+
Create the directory `~/Android/Sdk/` and unzip the platform-tools in this folder, so the absolute path to adb becomes
|
|
152
|
+
`~/Android/Sdk/platform-tools/adb`. Then create the environmental value `ANDROID_SDK_ROOT` with the value
|
|
153
|
+
`~/Android/Sdk/`:
|
|
133
154
|
|
|
134
155
|
```shell
|
|
135
156
|
$ echo 'export ANDROID_SDK_ROOT="$HOME/Android/Sdk/"' >> ~/.bashrc
|
|
136
157
|
$ source ~/.bashrc
|
|
137
158
|
```
|
|
159
|
+
|
|
138
160
|
> :warning: When running your Appium script from an IDE, you might get the error `Could not determine ANDROID_SDK_ROOT.`
|
|
139
161
|
> This is because the IDE might not load the environment variables correctly. Since Puma then defaults to ~/Android/Sdk,
|
|
140
|
-
> you will not need to do anything if you followed the steps above, and you can ignore this message. If you really want
|
|
162
|
+
> you will not need to do anything if you followed the steps above, and you can ignore this message. If you really want
|
|
141
163
|
> to use another location, please refer to you IDE specific documentation how to set environment variables.
|
|
142
164
|
|
|
143
165
|
### Appium
|
|
@@ -4,6 +4,7 @@ from typing import Dict
|
|
|
4
4
|
from appium.webdriver.common.appiumby import AppiumBy
|
|
5
5
|
|
|
6
6
|
from puma.apps.android.appium_actions import supported_version, AndroidAppiumActions
|
|
7
|
+
from puma.apps.android.telegram import logger
|
|
7
8
|
|
|
8
9
|
TELEGRAM_PACKAGE = 'org.telegram.messenger'
|
|
9
10
|
TELEGRAM_WEB_PACKAGE = 'org.telegram.messenger.web'
|
|
@@ -172,23 +173,34 @@ class TelegramActions(AndroidAppiumActions):
|
|
|
172
173
|
# click the attachment icon
|
|
173
174
|
self.driver.find_element(by=AppiumBy.XPATH,
|
|
174
175
|
value='//android.widget.ImageView[lower-case(@content-desc)="attach media"]').click()
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
|
|
177
|
+
camera_preview_xpath = '//android.widget.FrameLayout[@resource-id="android:id/content"]/android.widget.FrameLayout/android.widget.FrameLayout[2]'
|
|
178
|
+
shutter_xpath = '//android.widget.Button[lower-case(@content-desc)="shutter"]'
|
|
179
|
+
for i in range(10):
|
|
180
|
+
if self.is_present(camera_preview_xpath):
|
|
181
|
+
self.driver.find_element(by=AppiumBy.XPATH, value=camera_preview_xpath).click()
|
|
182
|
+
if self.is_present(shutter_xpath):
|
|
183
|
+
break
|
|
184
|
+
sleep(1)
|
|
185
|
+
if not self.is_present(shutter_xpath):
|
|
186
|
+
raise Exception("Clicking the camera preview to take a picture failed.")
|
|
187
|
+
|
|
179
188
|
# switch camera if need be
|
|
180
189
|
if front_camera:
|
|
181
190
|
self.driver.find_element(by=AppiumBy.XPATH,
|
|
182
191
|
value='//android.widget.ImageView[lower-case(@content-desc)="switch camera"]').click()
|
|
183
192
|
sleep(wait_time)
|
|
184
193
|
# take picture
|
|
185
|
-
self.driver.find_element(by=AppiumBy.XPATH,
|
|
186
|
-
value='//android.widget.Button[lower-case(@content-desc)="shutter"]').click()
|
|
187
|
-
sleep(1)
|
|
194
|
+
self.driver.find_element(by=AppiumBy.XPATH, value=shutter_xpath).click()
|
|
188
195
|
# add caption
|
|
189
196
|
if caption is not None:
|
|
190
|
-
|
|
191
|
-
|
|
197
|
+
text_field = '//android.widget.EditText'
|
|
198
|
+
for i in range(10):
|
|
199
|
+
if self.is_present(text_field):
|
|
200
|
+
break
|
|
201
|
+
sleep(1)
|
|
202
|
+
self.driver.find_element(by=AppiumBy.XPATH, value=text_field).click()
|
|
203
|
+
self.driver.find_element(by=AppiumBy.XPATH, value=text_field).send_keys(caption)
|
|
192
204
|
self.driver.find_element(by=AppiumBy.XPATH,
|
|
193
205
|
value='//android.widget.EditText/../../android.widget.ImageView').click()
|
|
194
206
|
# press send
|
|
@@ -219,10 +231,11 @@ class TelegramActions(AndroidAppiumActions):
|
|
|
219
231
|
"""
|
|
220
232
|
Ends the current call. Assumes the call screen is open.
|
|
221
233
|
"""
|
|
222
|
-
if
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
234
|
+
if self._currently_in_call():
|
|
235
|
+
self.driver.find_element(by=AppiumBy.XPATH,
|
|
236
|
+
value='//android.widget.Button[lower-case(@text)="end call"]').click()
|
|
237
|
+
else:
|
|
238
|
+
logger.warn('Could not end call as current screen was not the call screen.')
|
|
226
239
|
|
|
227
240
|
def answer_call(self):
|
|
228
241
|
"""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
version = "2.3.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pumapy
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Home-page: https://github.com/NetherlandsForensicInstitute/puma
|
|
5
5
|
Author: Netherlands Forensic Institute
|
|
6
6
|
Author-email: netherlandsforensicinstitute@users.noreply.github.com
|
|
@@ -20,7 +20,7 @@ Requires-Dist: requests~=2.32.3
|
|
|
20
20
|
|
|
21
21
|
# Puma - Programmable Utility for Mobile Automation
|
|
22
22
|
|
|
23
|
-
Puma is a Python library for executing app-specific actions on mobile devices such as sending a message or starting a
|
|
23
|
+
Puma is a Python library for executing app-specific actions on mobile devices such as sending a message or starting a
|
|
24
24
|
call. The goal is that you can focus on *what* should happen rather than *how* this should happen, so rather than write
|
|
25
25
|
code to "tap on Bob's conversation on Alice's phone, enter the message, and press send", you can simply write "send a
|
|
26
26
|
Telegram message to Bob from Alice's phone".
|
|
@@ -28,33 +28,48 @@ Telegram message to Bob from Alice's phone".
|
|
|
28
28
|
To execute actions on the mobile device, Puma uses [Appium](https://appium.io/), and open-source project for UI
|
|
29
29
|
automation.
|
|
30
30
|
|
|
31
|
-
Puma
|
|
32
|
-
|
|
31
|
+
Puma was created at the NFI to improve our process of creating test and reference datasets. Our best practices on
|
|
32
|
+
creating test data can be found [here](docs/TESTDATA_GUIDELINES.md). If you are wondering whether you should make your
|
|
33
|
+
own test data, or whether you should use Puma for it, [this document](docs/TESTDATA_WHY.md) goes into the advantages of
|
|
34
|
+
doing so.
|
|
35
|
+
|
|
36
|
+
Puma is an open-source non-commercial project, and community contributions to add support for apps, or improve support
|
|
37
|
+
of existing apps are welcome! If you want to contribute, please read [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
33
38
|
|
|
34
39
|
> :no_mobile_phones: Puma currently only supports Android apps. iOS apps are on our to-do list!
|
|
40
|
+
|
|
35
41
|
## Getting started
|
|
42
|
+
|
|
36
43
|
1. Install all required software (see the [requirements](#requirements) section).
|
|
37
44
|
- install [ADB](#ADB)
|
|
38
45
|
- install [Appium](#Appium)
|
|
39
|
-
2. Connect your Android device (or start an emulator), make sure it is connected properly over ADB (See the
|
|
40
|
-
[troubleshooting](#Troubleshooting) if you encounter problems).
|
|
46
|
+
2. Connect your Android device (or start an emulator), make sure it is connected properly over ADB (See the section on
|
|
47
|
+
[troubleshooting](#Troubleshooting) if you encounter problems).
|
|
41
48
|
- :warn: Make sure the phone is set to English, and [all other requirements](#Android-Devices-or-Emulators) are met!
|
|
42
|
-
3. Get the UDID of your device by running `adb devices` (in the example below `954724ertyui74125` is the UDID of the
|
|
49
|
+
3. Get the UDID of your device by running `adb devices` (in the example below `954724ertyui74125` is the UDID of the
|
|
50
|
+
device):
|
|
51
|
+
|
|
43
52
|
```shell
|
|
44
53
|
$ adb devices
|
|
45
54
|
> List of devices attached
|
|
46
55
|
954724ertyui74125 device
|
|
47
56
|
```
|
|
57
|
+
|
|
48
58
|
4. Install Puma. We recommend always installing packages within [a Python venv](https://docs.python.org/3/library/venv.html).
|
|
59
|
+
|
|
49
60
|
```shell
|
|
50
61
|
pip install pumapy
|
|
51
62
|
```
|
|
63
|
+
|
|
52
64
|
5. Run Appium. This starts the Appium server, a process that needs to run while you use Puma.
|
|
65
|
+
|
|
53
66
|
```shell
|
|
54
67
|
appium
|
|
55
68
|
```
|
|
69
|
+
|
|
56
70
|
Now you can use Puma! The code below is a small example on how to send a WhatsApp message, you can run this on a phone
|
|
57
71
|
that has WhatsApp installed and has a registered WhatsApp account:
|
|
72
|
+
|
|
58
73
|
```python
|
|
59
74
|
from puma.apps.android.whatsapp.whatsapp import WhatsappActions
|
|
60
75
|
|
|
@@ -62,9 +77,11 @@ alice = WhatsappActions("<INSERT UDID HERE>") # Initialize a connection with de
|
|
|
62
77
|
alice.create_new_chat(contact="<Insert the contact name>", first_message="Hello world!") # Send a message to contact in your contact list
|
|
63
78
|
alice.send_message("Sorry for the spam :)") # we can send a second message in the open conversation
|
|
64
79
|
```
|
|
80
|
+
|
|
65
81
|
Congratulations, you just sent a WhatsApp message without touching your phone!
|
|
66
82
|
You can now explore what other function are possible with Puma in [WhatsApp](puma/apps/android/whatsapp/README.md), or
|
|
67
|
-
try a [different application](#supported-apps). Or you could even start working
|
|
83
|
+
try a [different application](#supported-apps). Or you could even start working
|
|
84
|
+
on [adding support for a new app](CONTRIBUTING.md).
|
|
68
85
|
|
|
69
86
|
## Supported apps
|
|
70
87
|
|
|
@@ -74,6 +91,7 @@ example implementations:
|
|
|
74
91
|
* [WhatsApp](puma/apps/android/whatsapp/README.md)
|
|
75
92
|
* [Telegram](puma/apps/android/telegram/README.md)
|
|
76
93
|
* [Snapchat](puma/apps/android/snapchat/README.md)
|
|
94
|
+
* [Google Maps](puma/apps/android/google_maps/README.md)
|
|
77
95
|
|
|
78
96
|
Right now only Android is supported.
|
|
79
97
|
|
|
@@ -94,11 +112,13 @@ to use an older release of Puma.
|
|
|
94
112
|
To make it easy for users to lookup older versions, git tags will be used to tag app versions. So in the above example
|
|
95
113
|
you'd simply have to look up the tag `Xyz_v2`.
|
|
96
114
|
|
|
97
|
-
If you are running your script on a newer app version
|
|
98
|
-
app (can be found in the [test scripts directory](test_scripts)). This test script includes each action that can be
|
|
99
|
-
you if all actions are still supported, without messing up
|
|
115
|
+
If you are running your script on a newer app version than the tag, it is advised to first run the test script of your
|
|
116
|
+
app (can be found in the [test scripts directory](test_scripts)). This test script includes each action that can be
|
|
117
|
+
performed on the phone, and running these first will inform you if all actions are still supported, without messing up
|
|
118
|
+
your experiment.
|
|
100
119
|
|
|
101
120
|
#### Navigation
|
|
121
|
+
|
|
102
122
|
You need to be careful about navigation. For example, some methods require you to already be in a conversation. However,
|
|
103
123
|
most methods give you the option to navigate to a specific conversation. 2 examples:
|
|
104
124
|
|
|
@@ -148,16 +168,18 @@ sudo apt install python3.11
|
|
|
148
168
|
|
|
149
169
|
Puma uses ADB to connect to Android devices for some features, both directly and through Appium.
|
|
150
170
|
To install ADB, download [the Android Sdk Platform Tools](https://developer.android.com/tools/releases/platform-tools).
|
|
151
|
-
Create the directory `~/Android/Sdk/` and unzip the platform-tools in this folder, so the absolute path to adb becomes
|
|
152
|
-
Then create the environmental value `ANDROID_SDK_ROOT` with the value
|
|
171
|
+
Create the directory `~/Android/Sdk/` and unzip the platform-tools in this folder, so the absolute path to adb becomes
|
|
172
|
+
`~/Android/Sdk/platform-tools/adb`. Then create the environmental value `ANDROID_SDK_ROOT` with the value
|
|
173
|
+
`~/Android/Sdk/`:
|
|
153
174
|
|
|
154
175
|
```shell
|
|
155
176
|
$ echo 'export ANDROID_SDK_ROOT="$HOME/Android/Sdk/"' >> ~/.bashrc
|
|
156
177
|
$ source ~/.bashrc
|
|
157
178
|
```
|
|
179
|
+
|
|
158
180
|
> :warning: When running your Appium script from an IDE, you might get the error `Could not determine ANDROID_SDK_ROOT.`
|
|
159
181
|
> This is because the IDE might not load the environment variables correctly. Since Puma then defaults to ~/Android/Sdk,
|
|
160
|
-
> you will not need to do anything if you followed the steps above, and you can ignore this message. If you really want
|
|
182
|
+
> you will not need to do anything if you followed the steps above, and you can ignore this message. If you really want
|
|
161
183
|
> to use another location, please refer to you IDE specific documentation how to set environment variables.
|
|
162
184
|
|
|
163
185
|
### Appium
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import re
|
|
3
|
+
import unittest
|
|
4
|
+
from puma.utils import PROJECT_ROOT
|
|
5
|
+
from puma.version import version as setup_version
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def read_release_notes(file_path: str) -> [str]:
|
|
9
|
+
"""
|
|
10
|
+
Read the content of the release notes file.
|
|
11
|
+
:param file_path: The path to the release notes file.
|
|
12
|
+
:return: The content of the release notes file.
|
|
13
|
+
"""
|
|
14
|
+
with open(file_path, 'r') as file:
|
|
15
|
+
return file.readlines()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class TestVersion(unittest.TestCase):
|
|
19
|
+
|
|
20
|
+
def setUp(self):
|
|
21
|
+
self.release_notes_path = f"{PROJECT_ROOT}/RELEASE_NOTES"
|
|
22
|
+
self.release_notes = read_release_notes(self.release_notes_path)
|
|
23
|
+
self.first_version_in_release_notes = self._get_first_version_in_release_notes()
|
|
24
|
+
|
|
25
|
+
def _get_first_version_in_release_notes(self):
|
|
26
|
+
first_line = self.release_notes[0]
|
|
27
|
+
match = re.search(r'(\d+\.\d+\.\d+)', first_line)
|
|
28
|
+
return match.group(1) if match else None
|
|
29
|
+
|
|
30
|
+
def test_version_in_release_notes_same_as_setup(self):
|
|
31
|
+
self.assertIsNotNone(self.first_version_in_release_notes)
|
|
32
|
+
self.assertEqual(self.first_version_in_release_notes, setup_version,
|
|
33
|
+
"Version in release notes is not equal to setup version")
|
|
34
|
+
|
|
35
|
+
def test_versions_same_as_github(self):
|
|
36
|
+
github_tag_version = os.getenv('GITHUB_TAG_VERSION')
|
|
37
|
+
# Only run this test when a release is made from GitHub (i.e. the above environment variable is set)
|
|
38
|
+
if github_tag_version is None:
|
|
39
|
+
self.skipTest("Skipping GitHub version test as no tag version was passed.")
|
|
40
|
+
|
|
41
|
+
self.assertEqual(github_tag_version, self.first_version_in_release_notes,
|
|
42
|
+
"GitHub tag version is not equal to top version in release notes")
|
|
43
|
+
self.assertEqual(github_tag_version, setup_version,
|
|
44
|
+
"GitHub tag version is not equal to setup version")
|
|
File without changes
|
pumapy-2.2.0/puma/version.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
version = "2.2.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pumapy-2.2.0/puma/apps/android/telegram → pumapy-2.3.0/puma/apps/android/whatsapp}/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|