Kea2-python 0.0.1a0__tar.gz → 0.0.1a2__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.

Potentially problematic release.


This version of Kea2-python might be problematic. Click here for more details.

Files changed (40) hide show
  1. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/Kea2_python.egg-info/PKG-INFO +17 -57
  2. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/PKG-INFO +17 -57
  3. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/README.md +16 -56
  4. kea2_python-0.0.1a2/kea2/assets/fastbot_configs/widget.block.py +18 -0
  5. kea2_python-0.0.1a2/kea2/assets/monkeyq.jar +0 -0
  6. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/assets/quickstart.py +9 -1
  7. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/cli.py +18 -13
  8. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/keaUtils.py +24 -7
  9. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/kea_launcher.py +19 -11
  10. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/u2Driver.py +14 -4
  11. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/pyproject.toml +1 -1
  12. kea2_python-0.0.1a0/kea2/assets/fastbot_configs/widget.block.py +0 -22
  13. kea2_python-0.0.1a0/kea2/assets/monkeyq.jar +0 -0
  14. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/Kea2_python.egg-info/SOURCES.txt +0 -0
  15. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/Kea2_python.egg-info/dependency_links.txt +0 -0
  16. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/Kea2_python.egg-info/entry_points.txt +0 -0
  17. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/Kea2_python.egg-info/requires.txt +0 -0
  18. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/Kea2_python.egg-info/top_level.txt +0 -0
  19. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/LICENSE +0 -0
  20. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/__init__.py +0 -0
  21. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/absDriver.py +0 -0
  22. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/adbUtils.py +0 -0
  23. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/assets/fastbot-thirdpart.jar +0 -0
  24. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/assets/fastbot_configs/ADBKeyBoard.apk +0 -0
  25. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/assets/fastbot_configs/abl.strings +0 -0
  26. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/assets/fastbot_configs/awl.strings +0 -0
  27. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/assets/fastbot_configs/max.config +0 -0
  28. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/assets/fastbot_configs/max.fuzzing.strings +0 -0
  29. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/assets/fastbot_configs/max.schema.strings +0 -0
  30. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/assets/fastbot_configs/max.strings +0 -0
  31. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/assets/fastbot_configs/max.tree.pruning +0 -0
  32. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/assets/fastbot_libs/arm64-v8a/libfastbot_native.so +0 -0
  33. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/assets/fastbot_libs/armeabi-v7a/libfastbot_native.so +0 -0
  34. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/assets/fastbot_libs/x86/libfastbot_native.so +0 -0
  35. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/assets/fastbot_libs/x86_64/libfastbot_native.so +0 -0
  36. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/assets/framework.jar +0 -0
  37. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/assets/u2.jar +0 -0
  38. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/logWatcher.py +0 -0
  39. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/kea2/utils.py +0 -0
  40. {kea2_python-0.0.1a0 → kea2_python-0.0.1a2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Kea2-python
3
- Version: 0.0.1a0
3
+ Version: 0.0.1a2
4
4
  Summary: A python library for supporting and customizing automated UI testing for mobile apps
5
5
  Author-email: Xixian Liang <xixian@stu.ecnu.edu.cn>
6
6
  Requires-Python: >=3.9
@@ -48,59 +48,20 @@ In the future, Kea2 will be extended to support
48
48
 
49
49
  > Kea2 is inspired by many valuable insights, advices and lessons shared by experienced industrial practitioners from Bytedance (Zhao Zhang, Yuhui Su from the Fastbot team), OPay (Tiesong Liu), WeChat (Haochuan Lu), Huawei, Xiaomi and etc. Kudos!
50
50
 
51
-
52
- # Deploy Kea2
53
-
54
51
  ## Installation
55
52
 
56
53
  Running requirements/environment:
57
54
  - support Windows, MacOS and Linux
58
- - python 3.8+
55
+ - python 3.9+
59
56
  - Android SDK installed
60
57
  - **VPN closed** (Features 2 and 3 required)
61
58
 
62
- 1. Clone `Kea2` into your workspace.
63
-
64
- ```bash
65
- git clone git@github.com:ecnusse/Kea2.git
66
- cd Kea2
67
- ```
68
-
69
- 2. Setup the python virtual environment with `uv`.
70
-
71
- > [uv](https://github.com/astral-sh/uv) is a extremely fast python package and project manager. We use `uv` to create a python virtual environment for Kea2 to avoid any dependency issues or conflicts with your existing python environment.
72
- `uv` is similar to `virtualenv` but much more powerful.
73
- Of course, you can also setup Kea2 in your [global environment](https://github.com/ecnusse/Kea2/tree/dev?tab=readme-ov-file#appendix-install-kea2-in-a-global-environment).
74
-
75
59
  ```bash
76
- pip install --upgrade pip
77
- pip install uv
78
- uv sync
79
- ```
60
+ python3 -m pip install Kea2-python
80
61
 
81
- > MacOS users may have trouble with global pip install. In such cases, they can use `brew`.
82
- ```bash
83
- # For macOS users
84
- brew install uv
85
- uv sync
62
+ kea2 -h
86
63
  ```
87
64
 
88
- 3. Activate virtual environment
89
-
90
- - Linux and macOS
91
- ```bash
92
- source .venv/bin/activate
93
- ```
94
-
95
- - Windows cmd
96
- ```cmd
97
- \.venv\Scripts\activate.bat
98
- ```
99
-
100
- - Windows powershell
101
- ```powershell
102
- \.venv\Scripts\activate.ps1
103
- ```
104
65
 
105
66
  ## Quick Test
106
67
 
@@ -111,7 +72,8 @@ Kea2 connects to and runs on Android devices. We recommend you to do a quick tes
111
72
  2. Run `quickstart.py` to test a sample app `omninotes` (released as `omninotes.apk` in Kea2's repository). The script `quickstart.py` will automatically install and test this sample app for a short time.
112
73
 
113
74
  ```python
114
- python3 quickstart.py
75
+ kea2 init
76
+ python3 quickstart.py native
115
77
  ```
116
78
 
117
79
  If you can see the app `omninotes` is successfully running and tested, Kea2 works. Otherwise, please help [file a bug report](https://github.com/ecnusse/Kea2/issues) with the error message to us. Thank you!
@@ -133,7 +95,7 @@ Test your app with the full capability of [Fastbot](https://github.com/bytedance
133
95
 
134
96
 
135
97
  ```bash
136
- python3 kea_launcher.py driver -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent native --running-minutes 10 --throttle 200
98
+ kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent native --running-minutes 10 --throttle 200
137
99
  ```
138
100
 
139
101
  The usage is similar to the the original [Fastbot](https://github.com/bytedance/Fastbot_Android?tab=readme-ov-file#run-fastbot-with-shell-command)'s shell commands.
@@ -185,19 +147,17 @@ In this case, the `Home` page is the entry page of the `Privacy` page and the `H
185
147
  - In script's test method `test_goToPrivacy`, we specify the interaction logic (i.e., opening `Drawer`, clicking the option `Setting` and clicking `Privacy`) to guide Fastbot to reach the `Privacy` page.
186
148
  - By the decorator `@prob`, we specify the probability (50% in this example) to do the guidance when we are at the `Home` page. As a result, Kea2 still allows Fastbot to explore other pages.
187
149
 
188
- You can find the full example in script `quickstart2.py` and run it by executing:
150
+ You can find the full example in script `quickstart.py` and run it by executing:
189
151
 
152
+ ```python
153
+ python3 quickstart.py u2
154
+ ```
190
155
 
191
156
  ```bash
192
- # Launch Kea2 and load one single script quickstart2.py.
193
- python3 kea_launcher.py driver -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest quickstart2.py
157
+ # Launch Kea2 and load one single script quickstart.py.
158
+ kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest quickstart.py
194
159
  ```
195
160
 
196
- or simply run:
197
-
198
- ```python
199
- python3 quickstart2.py
200
- ```
201
161
 
202
162
 
203
163
 
@@ -294,21 +254,21 @@ We offer two ways to launch Kea2.
294
254
 
295
255
  ### 1. Launch by shell commands
296
256
 
297
- Kea2 is compatible with `unittest` framework. You can manage your test cases in unittest style. You can launch Kea2 with `kea_launcher.py` with two sub-commands `driver` (for Kea2 options) and `unittest` (for unittest options).
257
+ Kea2 is compatible with `unittest` framework. You can manage your test cases in unittest style. You can launch Kea2 with `kea run` with driver options and sub-command `unittest` (for unittest options).
298
258
 
299
259
  The shell command:
300
260
  ```
301
- python3 kea_launcher.py driver <Kea2 cmds> unittest <unittest cmds>
261
+ kea2 run <Kea2 cmds> unittest <unittest cmds>
302
262
  ```
303
263
 
304
264
  Sample shell commands:
305
265
 
306
266
  ```bash
307
267
  # Launch Kea2 and load one single script quickstart.py.
308
- python3 kea_launcher.py driver -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest quickstart.py
268
+ kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest quickstart.py
309
269
 
310
270
  # Launch Kea2 and load multiple scripts from the directory mytests/omni_notes
311
- python3 kea_launcher.py driver -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest discover -s mytests/omni_notes
271
+ kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest discover -s mytests/omni_notes
312
272
  ```
313
273
 
314
274
  | arg | meaning |
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Kea2-python
3
- Version: 0.0.1a0
3
+ Version: 0.0.1a2
4
4
  Summary: A python library for supporting and customizing automated UI testing for mobile apps
5
5
  Author-email: Xixian Liang <xixian@stu.ecnu.edu.cn>
6
6
  Requires-Python: >=3.9
@@ -48,59 +48,20 @@ In the future, Kea2 will be extended to support
48
48
 
49
49
  > Kea2 is inspired by many valuable insights, advices and lessons shared by experienced industrial practitioners from Bytedance (Zhao Zhang, Yuhui Su from the Fastbot team), OPay (Tiesong Liu), WeChat (Haochuan Lu), Huawei, Xiaomi and etc. Kudos!
50
50
 
51
-
52
- # Deploy Kea2
53
-
54
51
  ## Installation
55
52
 
56
53
  Running requirements/environment:
57
54
  - support Windows, MacOS and Linux
58
- - python 3.8+
55
+ - python 3.9+
59
56
  - Android SDK installed
60
57
  - **VPN closed** (Features 2 and 3 required)
61
58
 
62
- 1. Clone `Kea2` into your workspace.
63
-
64
- ```bash
65
- git clone git@github.com:ecnusse/Kea2.git
66
- cd Kea2
67
- ```
68
-
69
- 2. Setup the python virtual environment with `uv`.
70
-
71
- > [uv](https://github.com/astral-sh/uv) is a extremely fast python package and project manager. We use `uv` to create a python virtual environment for Kea2 to avoid any dependency issues or conflicts with your existing python environment.
72
- `uv` is similar to `virtualenv` but much more powerful.
73
- Of course, you can also setup Kea2 in your [global environment](https://github.com/ecnusse/Kea2/tree/dev?tab=readme-ov-file#appendix-install-kea2-in-a-global-environment).
74
-
75
59
  ```bash
76
- pip install --upgrade pip
77
- pip install uv
78
- uv sync
79
- ```
60
+ python3 -m pip install Kea2-python
80
61
 
81
- > MacOS users may have trouble with global pip install. In such cases, they can use `brew`.
82
- ```bash
83
- # For macOS users
84
- brew install uv
85
- uv sync
62
+ kea2 -h
86
63
  ```
87
64
 
88
- 3. Activate virtual environment
89
-
90
- - Linux and macOS
91
- ```bash
92
- source .venv/bin/activate
93
- ```
94
-
95
- - Windows cmd
96
- ```cmd
97
- \.venv\Scripts\activate.bat
98
- ```
99
-
100
- - Windows powershell
101
- ```powershell
102
- \.venv\Scripts\activate.ps1
103
- ```
104
65
 
105
66
  ## Quick Test
106
67
 
@@ -111,7 +72,8 @@ Kea2 connects to and runs on Android devices. We recommend you to do a quick tes
111
72
  2. Run `quickstart.py` to test a sample app `omninotes` (released as `omninotes.apk` in Kea2's repository). The script `quickstart.py` will automatically install and test this sample app for a short time.
112
73
 
113
74
  ```python
114
- python3 quickstart.py
75
+ kea2 init
76
+ python3 quickstart.py native
115
77
  ```
116
78
 
117
79
  If you can see the app `omninotes` is successfully running and tested, Kea2 works. Otherwise, please help [file a bug report](https://github.com/ecnusse/Kea2/issues) with the error message to us. Thank you!
@@ -133,7 +95,7 @@ Test your app with the full capability of [Fastbot](https://github.com/bytedance
133
95
 
134
96
 
135
97
  ```bash
136
- python3 kea_launcher.py driver -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent native --running-minutes 10 --throttle 200
98
+ kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent native --running-minutes 10 --throttle 200
137
99
  ```
138
100
 
139
101
  The usage is similar to the the original [Fastbot](https://github.com/bytedance/Fastbot_Android?tab=readme-ov-file#run-fastbot-with-shell-command)'s shell commands.
@@ -185,19 +147,17 @@ In this case, the `Home` page is the entry page of the `Privacy` page and the `H
185
147
  - In script's test method `test_goToPrivacy`, we specify the interaction logic (i.e., opening `Drawer`, clicking the option `Setting` and clicking `Privacy`) to guide Fastbot to reach the `Privacy` page.
186
148
  - By the decorator `@prob`, we specify the probability (50% in this example) to do the guidance when we are at the `Home` page. As a result, Kea2 still allows Fastbot to explore other pages.
187
149
 
188
- You can find the full example in script `quickstart2.py` and run it by executing:
150
+ You can find the full example in script `quickstart.py` and run it by executing:
189
151
 
152
+ ```python
153
+ python3 quickstart.py u2
154
+ ```
190
155
 
191
156
  ```bash
192
- # Launch Kea2 and load one single script quickstart2.py.
193
- python3 kea_launcher.py driver -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest quickstart2.py
157
+ # Launch Kea2 and load one single script quickstart.py.
158
+ kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest quickstart.py
194
159
  ```
195
160
 
196
- or simply run:
197
-
198
- ```python
199
- python3 quickstart2.py
200
- ```
201
161
 
202
162
 
203
163
 
@@ -294,21 +254,21 @@ We offer two ways to launch Kea2.
294
254
 
295
255
  ### 1. Launch by shell commands
296
256
 
297
- Kea2 is compatible with `unittest` framework. You can manage your test cases in unittest style. You can launch Kea2 with `kea_launcher.py` with two sub-commands `driver` (for Kea2 options) and `unittest` (for unittest options).
257
+ Kea2 is compatible with `unittest` framework. You can manage your test cases in unittest style. You can launch Kea2 with `kea run` with driver options and sub-command `unittest` (for unittest options).
298
258
 
299
259
  The shell command:
300
260
  ```
301
- python3 kea_launcher.py driver <Kea2 cmds> unittest <unittest cmds>
261
+ kea2 run <Kea2 cmds> unittest <unittest cmds>
302
262
  ```
303
263
 
304
264
  Sample shell commands:
305
265
 
306
266
  ```bash
307
267
  # Launch Kea2 and load one single script quickstart.py.
308
- python3 kea_launcher.py driver -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest quickstart.py
268
+ kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest quickstart.py
309
269
 
310
270
  # Launch Kea2 and load multiple scripts from the directory mytests/omni_notes
311
- python3 kea_launcher.py driver -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest discover -s mytests/omni_notes
271
+ kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest discover -s mytests/omni_notes
312
272
  ```
313
273
 
314
274
  | arg | meaning |
@@ -36,59 +36,20 @@ In the future, Kea2 will be extended to support
36
36
 
37
37
  > Kea2 is inspired by many valuable insights, advices and lessons shared by experienced industrial practitioners from Bytedance (Zhao Zhang, Yuhui Su from the Fastbot team), OPay (Tiesong Liu), WeChat (Haochuan Lu), Huawei, Xiaomi and etc. Kudos!
38
38
 
39
-
40
- # Deploy Kea2
41
-
42
39
  ## Installation
43
40
 
44
41
  Running requirements/environment:
45
42
  - support Windows, MacOS and Linux
46
- - python 3.8+
43
+ - python 3.9+
47
44
  - Android SDK installed
48
45
  - **VPN closed** (Features 2 and 3 required)
49
46
 
50
- 1. Clone `Kea2` into your workspace.
51
-
52
- ```bash
53
- git clone git@github.com:ecnusse/Kea2.git
54
- cd Kea2
55
- ```
56
-
57
- 2. Setup the python virtual environment with `uv`.
58
-
59
- > [uv](https://github.com/astral-sh/uv) is a extremely fast python package and project manager. We use `uv` to create a python virtual environment for Kea2 to avoid any dependency issues or conflicts with your existing python environment.
60
- `uv` is similar to `virtualenv` but much more powerful.
61
- Of course, you can also setup Kea2 in your [global environment](https://github.com/ecnusse/Kea2/tree/dev?tab=readme-ov-file#appendix-install-kea2-in-a-global-environment).
62
-
63
47
  ```bash
64
- pip install --upgrade pip
65
- pip install uv
66
- uv sync
67
- ```
48
+ python3 -m pip install Kea2-python
68
49
 
69
- > MacOS users may have trouble with global pip install. In such cases, they can use `brew`.
70
- ```bash
71
- # For macOS users
72
- brew install uv
73
- uv sync
50
+ kea2 -h
74
51
  ```
75
52
 
76
- 3. Activate virtual environment
77
-
78
- - Linux and macOS
79
- ```bash
80
- source .venv/bin/activate
81
- ```
82
-
83
- - Windows cmd
84
- ```cmd
85
- \.venv\Scripts\activate.bat
86
- ```
87
-
88
- - Windows powershell
89
- ```powershell
90
- \.venv\Scripts\activate.ps1
91
- ```
92
53
 
93
54
  ## Quick Test
94
55
 
@@ -99,7 +60,8 @@ Kea2 connects to and runs on Android devices. We recommend you to do a quick tes
99
60
  2. Run `quickstart.py` to test a sample app `omninotes` (released as `omninotes.apk` in Kea2's repository). The script `quickstart.py` will automatically install and test this sample app for a short time.
100
61
 
101
62
  ```python
102
- python3 quickstart.py
63
+ kea2 init
64
+ python3 quickstart.py native
103
65
  ```
104
66
 
105
67
  If you can see the app `omninotes` is successfully running and tested, Kea2 works. Otherwise, please help [file a bug report](https://github.com/ecnusse/Kea2/issues) with the error message to us. Thank you!
@@ -121,7 +83,7 @@ Test your app with the full capability of [Fastbot](https://github.com/bytedance
121
83
 
122
84
 
123
85
  ```bash
124
- python3 kea_launcher.py driver -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent native --running-minutes 10 --throttle 200
86
+ kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent native --running-minutes 10 --throttle 200
125
87
  ```
126
88
 
127
89
  The usage is similar to the the original [Fastbot](https://github.com/bytedance/Fastbot_Android?tab=readme-ov-file#run-fastbot-with-shell-command)'s shell commands.
@@ -173,19 +135,17 @@ In this case, the `Home` page is the entry page of the `Privacy` page and the `H
173
135
  - In script's test method `test_goToPrivacy`, we specify the interaction logic (i.e., opening `Drawer`, clicking the option `Setting` and clicking `Privacy`) to guide Fastbot to reach the `Privacy` page.
174
136
  - By the decorator `@prob`, we specify the probability (50% in this example) to do the guidance when we are at the `Home` page. As a result, Kea2 still allows Fastbot to explore other pages.
175
137
 
176
- You can find the full example in script `quickstart2.py` and run it by executing:
138
+ You can find the full example in script `quickstart.py` and run it by executing:
177
139
 
140
+ ```python
141
+ python3 quickstart.py u2
142
+ ```
178
143
 
179
144
  ```bash
180
- # Launch Kea2 and load one single script quickstart2.py.
181
- python3 kea_launcher.py driver -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest quickstart2.py
145
+ # Launch Kea2 and load one single script quickstart.py.
146
+ kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest quickstart.py
182
147
  ```
183
148
 
184
- or simply run:
185
-
186
- ```python
187
- python3 quickstart2.py
188
- ```
189
149
 
190
150
 
191
151
 
@@ -282,21 +242,21 @@ We offer two ways to launch Kea2.
282
242
 
283
243
  ### 1. Launch by shell commands
284
244
 
285
- Kea2 is compatible with `unittest` framework. You can manage your test cases in unittest style. You can launch Kea2 with `kea_launcher.py` with two sub-commands `driver` (for Kea2 options) and `unittest` (for unittest options).
245
+ Kea2 is compatible with `unittest` framework. You can manage your test cases in unittest style. You can launch Kea2 with `kea run` with driver options and sub-command `unittest` (for unittest options).
286
246
 
287
247
  The shell command:
288
248
  ```
289
- python3 kea_launcher.py driver <Kea2 cmds> unittest <unittest cmds>
249
+ kea2 run <Kea2 cmds> unittest <unittest cmds>
290
250
  ```
291
251
 
292
252
  Sample shell commands:
293
253
 
294
254
  ```bash
295
255
  # Launch Kea2 and load one single script quickstart.py.
296
- python3 kea_launcher.py driver -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest quickstart.py
256
+ kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest quickstart.py
297
257
 
298
258
  # Launch Kea2 and load multiple scripts from the directory mytests/omni_notes
299
- python3 kea_launcher.py driver -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest discover -s mytests/omni_notes
259
+ kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest discover -s mytests/omni_notes
300
260
  ```
301
261
 
302
262
  | arg | meaning |
@@ -0,0 +1,18 @@
1
+ from kea2.utils import Device
2
+ from kea2.keaUtils import precondition
3
+
4
+
5
+ def global_block_widgets(d: "Device"):
6
+ """
7
+ global block widgets.
8
+ return the widgets you want to block globally
9
+ only available in mode `u2 agent`
10
+ """
11
+ return []
12
+
13
+
14
+ # conditional block list
15
+ @precondition(lambda d: d(text="In the home page").exists)
16
+ def block_sth(d: "Device"):
17
+ # Important: function shold starts with "block"
18
+ return [d(text="widgets to block"), d.xpath(".//node[@text='widget to block']")]
@@ -73,7 +73,15 @@ def check_installation():
73
73
  d.stop_uiautomator()
74
74
 
75
75
 
76
+ def _get_agent():
77
+ import sys
78
+ if len(sys.argv) == 0 or sys.argv[1] == "u2":
79
+ return "u2"
80
+ return "native"
81
+
76
82
  if __name__ == "__main__":
83
+
84
+ AGENT=_get_agent()
77
85
  check_installation()
78
86
  KeaTestRunner.setOptions(
79
87
  Options(
@@ -84,7 +92,7 @@ if __name__ == "__main__":
84
92
  maxStep=5000,
85
93
  # running_mins=10, # specify the maximal running time in minutes, default value is 10m
86
94
  # throttle=200, # specify the throttle in milliseconds, default value is 200ms
87
- # agent='native' # 'native' for running the vanilla Fastbot, 'u2' for running Kea2
95
+ agent=AGENT # 'native' for running the vanilla Fastbot, 'u2' for running Kea2
88
96
  )
89
97
  )
90
98
  unittest.main(testRunner=KeaTestRunner)
@@ -2,6 +2,7 @@
2
2
  # cli.py
3
3
 
4
4
  from __future__ import absolute_import, print_function
5
+ import sys
5
6
  from kea2.utils import getProjectRoot, getLogger
6
7
  from .kea_launcher import run
7
8
  import argparse
@@ -43,9 +44,7 @@ def cmd_run(args):
43
44
  if base_dir is None:
44
45
  logger.error("kea2 project not initialized. Use `kea2 init`.")
45
46
  return
46
- argv = [__file__]
47
- argv.extend(args.args)
48
- run(argv)
47
+ run(args)
49
48
 
50
49
 
51
50
  def cmd_install(args):
@@ -83,14 +82,14 @@ _commands = [
83
82
  command="init",
84
83
  help="init the Kea2 project in current directory",
85
84
  ),
86
- dict(
87
- action=cmd_run,
88
- command="run",
89
- help="run kea2",
90
- flags=[
91
- dict(args=["args"], nargs=argparse.REMAINDER, help="args for kea2 run"),
92
- ],
93
- ),
85
+ # dict(
86
+ # action=cmd_run,
87
+ # command="run",
88
+ # help="run kea2",
89
+ # flags=[
90
+ # dict(args=["args"], nargs=argparse.REMAINDER),
91
+ # ],
92
+ # ),
94
93
  # dict(
95
94
  # action=cmd_install,
96
95
  # command="",
@@ -157,11 +156,17 @@ def main():
157
156
  kwargs.pop('args', None)
158
157
  sp.add_argument(*args, **kwargs)
159
158
 
159
+ from .kea_launcher import _set_driver_parser
160
+ _set_driver_parser(subparser)
161
+ actions["run"] = cmd_run
162
+ if sys.argv[1:] == ["run"]:
163
+ sys.argv.append("-h")
160
164
  args = parser.parse_args()
161
-
162
165
 
166
+ import logging
167
+ logging.getLogger("urllib3").setLevel(logging.INFO)
168
+ logging.getLogger("uiautomator2").setLevel(logging.INFO)
163
169
  if args.debug:
164
- import logging
165
170
  logging.basicConfig(level=logging.DEBUG)
166
171
  logger.debug("args: %s", args)
167
172
 
@@ -15,6 +15,8 @@ from time import sleep
15
15
  from .adbUtils import push_file
16
16
  from .logWatcher import LogWatcher
17
17
  from .utils import TimeStamp, getProjectRoot, getLogger
18
+ from .u2Driver import StaticU2UiObject
19
+ import uiautomator2 as u2
18
20
  import types
19
21
  PRECONDITIONS_MARKER = "preconds"
20
22
  PROP_MARKER = "prop"
@@ -404,8 +406,14 @@ class KeaTestRunner(TextTestRunner):
404
406
  """
405
407
  send a step monkey request to the server and get the xml string.
406
408
  """
407
- block_widgets = self._getBlockedWidgets()
408
- r = requests.get(f"http://localhost:{self.scriptDriver.lport}/stepMonkey")
409
+ block_widgets: List[str] = self._getBlockedWidgets()
410
+ URL = f"http://localhost:{self.scriptDriver.lport}/stepMonkey"
411
+ r = requests.post(
412
+ url=URL,
413
+ json={
414
+ "block_widgets": block_widgets
415
+ }
416
+ )
409
417
 
410
418
  res = json.loads(r.content)
411
419
  xml_raw = res["result"]
@@ -479,7 +487,7 @@ class KeaTestRunner(TextTestRunner):
479
487
  print(f"[INFO] Load property: {getFullPropName(t)}", flush=True)
480
488
 
481
489
  @property
482
- def blockList(self):
490
+ def _blockWidgetFuncs(self):
483
491
  if self._block_widgets_funcs is None:
484
492
  self._block_widgets_funcs = list()
485
493
  root_dir = getProjectRoot()
@@ -512,7 +520,7 @@ class KeaTestRunner(TextTestRunner):
512
520
 
513
521
  def _getBlockedWidgets(self):
514
522
  blocked_widgets = list()
515
- for func in self.blockList:
523
+ for func in self._blockWidgetFuncs:
516
524
  try:
517
525
  script_driver = self.options.Driver.getScriptDriver()
518
526
  preconds = getattr(func, PRECONDITIONS_MARKER)
@@ -520,9 +528,18 @@ class KeaTestRunner(TextTestRunner):
520
528
  _widgets = func(self.options.Driver.getStaticChecker())
521
529
  if not isinstance(_widgets, list):
522
530
  _widgets = [_widgets]
523
- blocked_widgets.extend([
524
- w._getXPath(w.selector) for w in _widgets
525
- ])
531
+ for w in _widgets:
532
+ if isinstance(w, StaticU2UiObject):
533
+ blocked_widgets.append(w._getXPath(w.selector))
534
+ elif isinstance(w, u2.xpath.XPathSelector):
535
+ def getXPathRepr(w):
536
+ return w._parent.xpath
537
+ blocked_widgets.append(getXPathRepr(w))
538
+ else:
539
+ logger.warning(f"{w} Not supported")
540
+ # blocked_widgets.extend([
541
+ # w._getXPath(w.selector) for w in _widgets
542
+ # ])
526
543
  except Exception as e:
527
544
  logger.error(f"error when getting blocked widgets: {e}")
528
545
  import traceback
@@ -1,9 +1,10 @@
1
+ import sys
1
2
  import argparse
2
- from typing import List
3
3
  import unittest
4
+ from typing import List
4
5
 
5
6
  def _set_driver_parser(subparsers: "argparse._SubParsersAction[argparse.ArgumentParser]"):
6
- parser = subparsers.add_parser("driver", help="Driver Settings")
7
+ parser = subparsers.add_parser("run", help="run kea2")
7
8
  parser.add_argument(
8
9
  "-s",
9
10
  "--serial",
@@ -96,21 +97,28 @@ def parse_args(argv: List):
96
97
  subparsers = parser.add_subparsers(dest="command", required=True)
97
98
 
98
99
  _set_driver_parser(subparsers)
99
- if len(argv) == 0:
100
- argv.append("-h")
101
100
  args = parser.parse_args(argv)
102
- driver_info_logger(args)
103
- unittest_info_logger(args)
104
101
  return args
105
102
 
106
- def run(argv=None):
107
- import sys
108
- if argv is None:
109
- argv = sys.argv
110
- args = parse_args(argv[1:])
103
+ def _sanitize_args(args):
104
+ if args.agent == "u2" and not args.driver_name:
105
+ if args.extra == []:
106
+ args.driver_name = "d"
107
+ else:
108
+ raise ValueError("--driver-name should be specified when customizing script in --agent u2")
109
+
110
+ def run(args=None):
111
+ if args is None:
112
+ args = parse_args(sys.argv[1:])
113
+
114
+ _sanitize_args(args)
115
+
116
+ driver_info_logger(args)
117
+ unittest_info_logger(args)
111
118
 
112
119
  from kea2 import KeaTestRunner, Options
113
120
  from kea2.u2Driver import U2Driver
121
+ U2Driver.setDeviceSerial(args.serial)
114
122
  options = Options(
115
123
  agent=args.agent,
116
124
  driverName=args.driver_name,
@@ -85,7 +85,8 @@ class StaticU2UiObject(u2.UiObject):
85
85
 
86
86
  def _transferU2Keys(self, originKey):
87
87
  filterDict = {
88
- "resourceId": "resource-id"
88
+ "resourceId": "resource-id",
89
+ "description": "content-desc"
89
90
  }
90
91
  if filterDict.get(originKey, None):
91
92
  return filterDict[originKey]
@@ -116,7 +117,7 @@ class StaticU2UiObject(u2.UiObject):
116
117
 
117
118
  @property
118
119
  def exists(self):
119
- self.selector["covered"] = "true"
120
+ dict.update(self.selector, {"covered": "true"})
120
121
  xpath = self._getXPath(self.selector)
121
122
  matched_widgets = self.session.xml.xpath(xpath)
122
123
  return bool(matched_widgets)
@@ -124,7 +125,7 @@ class StaticU2UiObject(u2.UiObject):
124
125
  def __len__(self):
125
126
  xpath = self._getXPath(self.selector)
126
127
  matched_widgets = self.session.xml.xpath(xpath)
127
- return len(matched_widgets)
128
+ return len(matched_widgets)
128
129
 
129
130
 
130
131
  def _get_bounds(raw_bounds):
@@ -216,12 +217,21 @@ class U2StaticDevice(u2.Device):
216
217
  def get_page_source(self):
217
218
  # print("[Debug] Using static get_page_source method")
218
219
  return u2.xpath.PageSource.parse(self._d.xml_raw)
219
- xpathEntry = u2.xpath.XPathEntry(self)
220
+ xpathEntry = _XPathEntry(self)
220
221
  xpathEntry.get_page_source = types.MethodType(
221
222
  get_page_source, xpathEntry
222
223
  )
223
224
  return xpathEntry
224
225
 
226
+ class _XPathEntry(u2.xpath.XPathEntry):
227
+ def __init__(self, d):
228
+ self.xpath = None
229
+ super().__init__(d)
230
+
231
+ def __call__(self, xpath, source = None):
232
+ self.xpath = xpath
233
+ return super().__call__(xpath, source)
234
+
225
235
 
226
236
  class U2StaticChecker(AbstractStaticChecker):
227
237
  """
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "Kea2-python"
3
- version = "0.0.1a"
3
+ version = "0.0.1a2"
4
4
  description = "A python library for supporting and customizing automated UI testing for mobile apps"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.9"
@@ -1,22 +0,0 @@
1
- from kea2.utils import precondition
2
- from uiautomator2 import Device
3
-
4
-
5
- @precondition(lambda d:
6
- d(text="Setting")
7
- )
8
- def sample_block_list(d: "Device"):
9
- return d(text="Omni Notes Alpha").exists
10
-
11
-
12
- if __name__ == "__main__":
13
- from kea2.utils import BLOCK_WIDGET
14
- func = getattr(sample_block_list, BLOCK_WIDGET)
15
- import uiautomator2 as u2
16
- d = u2.connect()
17
- blocked_widgets = func(d)
18
- if isinstance(blocked_widgets, u2.UiObject):
19
- blocked_widgets = [blocked_widgets]
20
- if not all([isinstance(w, u2.UiObject) for w in blocked_widgets]):
21
- raise TypeError(f"Invalid widgets block list in {sample_block_list}")
22
-
Binary file
File without changes
File without changes