Kea2-python 1.1.0__tar.gz → 1.1.0b1__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.
Files changed (57) hide show
  1. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/Kea2_python.egg-info/PKG-INFO +2 -6
  2. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/Kea2_python.egg-info/SOURCES.txt +1 -0
  3. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/PKG-INFO +2 -6
  4. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/README.md +1 -5
  5. kea2_python-1.1.0b1/kea2/absDriver.py +56 -0
  6. kea2_python-1.1.0b1/kea2/assets/monkeyq.jar +0 -0
  7. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/quicktest.py +21 -40
  8. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/cli.py +1 -9
  9. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/fastbotManager.py +3 -1
  10. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/kea2_api.py +3 -7
  11. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/keaUtils.py +135 -159
  12. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/kea_launcher.py +3 -1
  13. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/report/bug_report_generator.py +29 -54
  14. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/report/mixin.py +8 -9
  15. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/report/templates/bug_report_template.html +18 -106
  16. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/result.py +7 -9
  17. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/resultSyncer.py +1 -2
  18. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/u2Driver.py +4 -3
  19. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/utils.py +0 -47
  20. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/pyproject.toml +1 -1
  21. kea2_python-1.1.0/kea2/assets/monkeyq.jar +0 -0
  22. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/Kea2_python.egg-info/dependency_links.txt +0 -0
  23. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/Kea2_python.egg-info/entry_points.txt +0 -0
  24. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/Kea2_python.egg-info/requires.txt +0 -0
  25. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/Kea2_python.egg-info/top_level.txt +0 -0
  26. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/LICENSE +0 -0
  27. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/__init__.py +0 -0
  28. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/adbUtils.py +0 -0
  29. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/config_version.json +0 -0
  30. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/fastbot-thirdpart.jar +0 -0
  31. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/fastbot_configs/abl.strings +0 -0
  32. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/fastbot_configs/awl.strings +0 -0
  33. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/fastbot_configs/max.config +0 -0
  34. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/fastbot_configs/max.fuzzing.strings +0 -0
  35. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/fastbot_configs/max.schema.strings +0 -0
  36. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/fastbot_configs/max.strings +0 -0
  37. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/fastbot_configs/max.tree.pruning +0 -0
  38. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/fastbot_configs/teardown.py +0 -0
  39. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/fastbot_configs/widget.block.py +0 -0
  40. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/fastbot_libs/arm64-v8a/libfastbot_native.so +0 -0
  41. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/fastbot_libs/armeabi-v7a/libfastbot_native.so +0 -0
  42. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/fastbot_libs/x86/libfastbot_native.so +0 -0
  43. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/fastbot_libs/x86_64/libfastbot_native.so +0 -0
  44. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/framework.jar +0 -0
  45. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/assets/kea2-thirdpart.jar +0 -0
  46. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/logWatcher.py +0 -0
  47. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/mixin.py +0 -0
  48. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/report/__init__.py +0 -0
  49. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/report/report_merger.py +0 -0
  50. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/report/templates/merged_bug_report_template.html +0 -0
  51. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/report/utils.py +0 -0
  52. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/state.py +0 -0
  53. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/typedefs.py +0 -0
  54. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/kea2/version_manager.py +0 -0
  55. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/setup.cfg +0 -0
  56. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/tests/test_u2Selector.py +0 -0
  57. {kea2_python-1.1.0 → kea2_python-1.1.0b1}/tests/test_xpath.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Kea2-python
3
- Version: 1.1.0
3
+ Version: 1.1.0b1
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.8
@@ -290,7 +290,7 @@ Some notes:
290
290
  3. You need to insert the following code template into your existing test cases: Here, you can add your own hook logic in the commented sections, including starting or stopping the appium session, cleaning up instances, etc. This depends on how you want to design the setup and teardown. Apart from that, you only need to configure the `option` parameter and `configs_path` parameter(where your directory `configs` located, btw, `configs`'s location dependon where you executed `kea2 init`), then pass it to the `run_kea2_testing` function.
291
291
 
292
292
  ```python
293
- from kea2 import Kea2Tester, Options
293
+ from kea2 import Kea2Tester, Options, U2Driver
294
294
 
295
295
  if os.environ.get('KEA2_HYBRID_MODE', '').lower() == 'true':
296
296
  '''
@@ -327,10 +327,6 @@ if os.environ.get('KEA2_HYBRID_MODE', '').lower() == 'true':
327
327
  Kea2 automatically generates a HTML test report after each testing session. You can find the report in `output/` under your working directory.
328
328
 
329
329
  You can also manually generate the test report by `kea2 report` (see `kea2 report -h` for details).
330
- Use `-s/--sync` to sync data from device before generating the report, and `-p/--path` to point to one or more result directories.
331
- For example:
332
- `kea2 report -p output/res_YYYYMMDDHH_xxxxxx`
333
- `kea2 report -s -p output/res_YYYYMMDDHH_xxxxxx`
334
330
 
335
331
  You can also merge the test report from multiple testing sessions by `kea2 merge` (see `kea2 merge -h` for details).
336
332
  The merged test report is quite useful if you would test your apps for multiple sessions.
@@ -8,6 +8,7 @@ Kea2_python.egg-info/entry_points.txt
8
8
  Kea2_python.egg-info/requires.txt
9
9
  Kea2_python.egg-info/top_level.txt
10
10
  kea2/__init__.py
11
+ kea2/absDriver.py
11
12
  kea2/adbUtils.py
12
13
  kea2/cli.py
13
14
  kea2/fastbotManager.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Kea2-python
3
- Version: 1.1.0
3
+ Version: 1.1.0b1
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.8
@@ -290,7 +290,7 @@ Some notes:
290
290
  3. You need to insert the following code template into your existing test cases: Here, you can add your own hook logic in the commented sections, including starting or stopping the appium session, cleaning up instances, etc. This depends on how you want to design the setup and teardown. Apart from that, you only need to configure the `option` parameter and `configs_path` parameter(where your directory `configs` located, btw, `configs`'s location dependon where you executed `kea2 init`), then pass it to the `run_kea2_testing` function.
291
291
 
292
292
  ```python
293
- from kea2 import Kea2Tester, Options
293
+ from kea2 import Kea2Tester, Options, U2Driver
294
294
 
295
295
  if os.environ.get('KEA2_HYBRID_MODE', '').lower() == 'true':
296
296
  '''
@@ -327,10 +327,6 @@ if os.environ.get('KEA2_HYBRID_MODE', '').lower() == 'true':
327
327
  Kea2 automatically generates a HTML test report after each testing session. You can find the report in `output/` under your working directory.
328
328
 
329
329
  You can also manually generate the test report by `kea2 report` (see `kea2 report -h` for details).
330
- Use `-s/--sync` to sync data from device before generating the report, and `-p/--path` to point to one or more result directories.
331
- For example:
332
- `kea2 report -p output/res_YYYYMMDDHH_xxxxxx`
333
- `kea2 report -s -p output/res_YYYYMMDDHH_xxxxxx`
334
330
 
335
331
  You can also merge the test report from multiple testing sessions by `kea2 merge` (see `kea2 merge -h` for details).
336
332
  The merged test report is quite useful if you would test your apps for multiple sessions.
@@ -275,7 +275,7 @@ Some notes:
275
275
  3. You need to insert the following code template into your existing test cases: Here, you can add your own hook logic in the commented sections, including starting or stopping the appium session, cleaning up instances, etc. This depends on how you want to design the setup and teardown. Apart from that, you only need to configure the `option` parameter and `configs_path` parameter(where your directory `configs` located, btw, `configs`'s location dependon where you executed `kea2 init`), then pass it to the `run_kea2_testing` function.
276
276
 
277
277
  ```python
278
- from kea2 import Kea2Tester, Options
278
+ from kea2 import Kea2Tester, Options, U2Driver
279
279
 
280
280
  if os.environ.get('KEA2_HYBRID_MODE', '').lower() == 'true':
281
281
  '''
@@ -312,10 +312,6 @@ if os.environ.get('KEA2_HYBRID_MODE', '').lower() == 'true':
312
312
  Kea2 automatically generates a HTML test report after each testing session. You can find the report in `output/` under your working directory.
313
313
 
314
314
  You can also manually generate the test report by `kea2 report` (see `kea2 report -h` for details).
315
- Use `-s/--sync` to sync data from device before generating the report, and `-p/--path` to point to one or more result directories.
316
- For example:
317
- `kea2 report -p output/res_YYYYMMDDHH_xxxxxx`
318
- `kea2 report -s -p output/res_YYYYMMDDHH_xxxxxx`
319
315
 
320
316
  You can also merge the test report from multiple testing sessions by `kea2 merge` (see `kea2 merge -h` for details).
321
317
  The merged test report is quite useful if you would test your apps for multiple sessions.
@@ -0,0 +1,56 @@
1
+ import abc
2
+
3
+
4
+ class AbstractScriptDriver(abc.ABC):
5
+ _instances = {}
6
+ def __new__(cls, *args, **kwargs):
7
+ if cls not in cls._instances:
8
+ cls._instances[cls] = super().__new__(cls)
9
+ return cls._instances[cls]
10
+
11
+ @abc.abstractmethod
12
+ def getInstance(self):
13
+ pass
14
+
15
+
16
+ class AbstractStaticChecker(abc.ABC):
17
+ _instances = {}
18
+ def __new__(cls, *args, **kwargs):
19
+ if cls not in cls._instances:
20
+ cls._instances[cls] = super().__new__(cls)
21
+ return cls._instances[cls]
22
+
23
+ @abc.abstractmethod
24
+ def getInstance(self):
25
+ pass
26
+
27
+ @abc.abstractmethod
28
+ def setHierarchy(hierarchy):
29
+ pass
30
+
31
+
32
+ class AbstractDriver(abc.ABC):
33
+ _instances = {}
34
+ def __new__(cls, *args, **kwargs):
35
+ if cls not in cls._instances:
36
+ cls._instances[cls] = super().__new__(cls)
37
+ return cls._instances[cls]
38
+
39
+ @classmethod
40
+ @abc.abstractmethod
41
+ def setDevice(self):
42
+ pass
43
+
44
+ @classmethod
45
+ @abc.abstractmethod
46
+ def getScriptDriver(self) -> AbstractScriptDriver:
47
+ pass
48
+
49
+ @classmethod
50
+ @abc.abstractmethod
51
+ def getStaticChecker(self, hierarchy) -> AbstractStaticChecker:
52
+ pass
53
+
54
+ @classmethod
55
+ @abc.abstractmethod
56
+ def tearDown(self): ...
@@ -2,43 +2,39 @@ import unittest
2
2
  import uiautomator2 as u2
3
3
 
4
4
  from time import sleep
5
- from kea2 import precondition, prob, KeaTestRunner, Options, keaTestLoader, invariant
5
+ from kea2 import precondition, prob, KeaTestRunner, Options, kea, keaTestLoader
6
+ from kea2.u2Driver import U2Driver
6
7
 
7
8
 
8
9
  class Omni_Notes_Sample(unittest.TestCase):
9
- d: u2.Device
10
10
 
11
- @classmethod
12
- def setUpClass(cls):
13
- """Here you can setup the initialize setting for uiautomator2
14
- """
15
- print("Setting driver settings")
16
- cls.d.settings["wait_timeout"] = 5.0
17
- cls.d.settings["operation_delay"] = (0, 1.0)
18
-
19
- @prob(0.5)
11
+ def setUp(self):
12
+ self.d = u2.connect()
13
+
14
+ @prob(0.2)
20
15
  @precondition(
21
16
  lambda self: self.d(description="Navigate up").exists
22
17
  )
23
- def navigate_up(self):
18
+ def test_goBack(self):
24
19
  print("Navigate back")
25
20
  self.d(description="Navigate up").click()
26
-
27
- @prob(0.5)
21
+ sleep(0.5)
22
+
23
+ @prob(0.2)
28
24
  @precondition(
29
- lambda self: self.d(description="drawer closed").exists and
30
- not self.d(text="Omni Notes Alpha").exists
25
+ lambda self: self.d(description="drawer closed").exists
31
26
  )
32
- def open_drawer(self):
27
+ def test_openDrawer(self):
33
28
  print("Open drawer")
34
29
  self.d(description="drawer closed").click()
30
+ sleep(0.5)
35
31
 
36
- @prob(0.7) # The probability of executing the function when precondition is satisfied.
32
+ @prob(0.5) # The probability of executing the function when precondition is satisfied.
37
33
  @precondition(
38
34
  lambda self: self.d(text="Omni Notes Alpha").exists
39
35
  and self.d(text="Settings").exists
40
36
  )
41
- def go_to_privacy_settings(self):
37
+ def test_goToPrivacy(self):
42
38
  """
43
39
  The ability to jump out of the UI tarpits
44
40
 
@@ -49,13 +45,14 @@ class Omni_Notes_Sample(unittest.TestCase):
49
45
  """
50
46
  print("trying to click Settings")
51
47
  self.d(text="Settings").click()
48
+ sleep(0.5)
52
49
  print("trying to click Privacy")
53
50
  self.d(text="Privacy").click()
54
51
 
55
52
  @precondition(
56
53
  lambda self: self.d(resourceId="it.feio.android.omninotes.alpha:id/search_src_text").exists
57
54
  )
58
- def rotation_should_not_close_the_search_input(self):
55
+ def test_rotation(self):
59
56
  """
60
57
  The ability to make assertion to find functional bug
61
58
 
@@ -68,28 +65,11 @@ class Omni_Notes_Sample(unittest.TestCase):
68
65
  """
69
66
  print("rotate the device")
70
67
  self.d.set_orientation("l")
68
+ sleep(2)
71
69
  self.d.set_orientation("n")
72
- assert self.d(resourceId="it.feio.android.omninotes.alpha:id/search_src_text").exists
70
+ sleep(2)
71
+ assert self.d(resourceId="it.feio.android.omninotes.alpha:id/search_src_text").exists()
73
72
 
74
- @invariant
75
- def search_button_and_search_input_box_should_not_exists_at_the_same_time(self):
76
- """Search input box and search button should not exists at the same time
77
- """
78
- search_input_box_exists = self.d(resourceId="it.feio.android.omninotes.alpha:id/search_src_text").exists
79
- serach_button_exists = self.d(resourceId="it.feio.android.omninotes.alpha:id/menu_search").exists
80
- if search_input_box_exists or serach_button_exists:
81
- assert search_input_box_exists ^ serach_button_exists
82
-
83
- @precondition(lambda self: "camera" in self.d.app_current().get("package", ""))
84
- def exit_camera(self):
85
- """Exit camera app if it is launched
86
- (fastbot can't exit camera app by itself, we use kea2 to exit it to aviod getting stuck in camera)
87
- """
88
- print("Exiting camera app")
89
- pkg_camera = self.d.app_current().get("package", "")
90
- print(f"Current package: {pkg_camera}")
91
- if "camera" in pkg_camera:
92
- self.d.app_stop(pkg_camera)
93
73
 
94
74
  URL = "https://github.com/federicoiosue/Omni-Notes/releases/download/6.2.0_alpha/OmniNotes-alphaRelease-6.2.0.apk"
95
75
  FALL_BACK_URL = "https://gitee.com/XixianLiang/Kea2/raw/main/omninotes.apk"
@@ -132,6 +112,7 @@ if __name__ == "__main__":
132
112
  KeaTestRunner.setOptions(
133
113
  Options(
134
114
  driverName="d",
115
+ Driver=U2Driver,
135
116
  packageNames=[PACKAGE_NAME],
136
117
  # serial="emulator-5554", # specify the serial
137
118
  maxStep=50,
@@ -58,8 +58,6 @@ def cmd_report(args):
58
58
  from .report.bug_report_generator import BugReportGenerator
59
59
  report_dirs = args.path
60
60
 
61
- sync_data = args.sync
62
-
63
61
  for report_dir in report_dirs:
64
62
  report_dir = Path(report_dir).resolve()
65
63
 
@@ -68,7 +66,7 @@ def cmd_report(args):
68
66
  continue
69
67
 
70
68
  logger.debug(f"Generating test report from directory: {report_dir}")
71
- BugReportGenerator(report_dir, sync_data).generate_report()
69
+ BugReportGenerator(report_dir).generate_report()
72
70
 
73
71
 
74
72
  def cmd_merge(args):
@@ -138,12 +136,6 @@ _commands = [
138
136
  nargs="+",
139
137
  required=True,
140
138
  help="Root directory path of the test results to generate report from"
141
- ),
142
- dict(
143
- name=["sync_data"],
144
- args=["-s", "--sync"],
145
- action="store_true",
146
- help="Sync data from device before generating report"
147
139
  )
148
140
  ]
149
141
  ),
@@ -237,7 +237,7 @@ class FastbotManager:
237
237
 
238
238
  outfile = open(self.log_file, "w", encoding="utf-8", buffering=1)
239
239
 
240
- logger.info("Options info: {}".format(self.options.to_dict()))
240
+ logger.info("Options info: {}".format(asdict(self.options)))
241
241
  logger.info("Launching fastbot with shell command:\n{}".format(" ".join(full_cmd)))
242
242
  logger.info("Fastbot log will be saved to {}".format(outfile.name))
243
243
 
@@ -265,3 +265,5 @@ class FastbotManager:
265
265
  self.thread.join()
266
266
 
267
267
 
268
+
269
+
@@ -106,15 +106,11 @@ class Kea2Tester:
106
106
 
107
107
  output_dir = self.options.output_dir
108
108
 
109
- from .utils import StampManager
109
+ from .keaUtils import STAMP, LOGFILE, RESFILE
110
110
 
111
111
  bug_report_path = output_dir / "bug_report.html"
112
- stamp_manager = StampManager()
113
- stamp = stamp_manager.stamp or self.options.log_stamp
114
- result_name = stamp_manager.result_file.name if stamp_manager.result_file else f"result_{stamp}.json"
115
- log_name = stamp_manager.log_file.name if stamp_manager.log_file else f"fastbot_{stamp}.log"
116
- result_json_path = output_dir / result_name
117
- log_file_path = output_dir / log_name
112
+ result_json_path = output_dir / RESFILE.name if hasattr(RESFILE, 'name') else output_dir / f"result_{STAMP}.json"
113
+ log_file_path = output_dir / LOGFILE.name if hasattr(LOGFILE, 'name') else output_dir / f"fastbot_{STAMP}.log"
118
114
 
119
115
  return {
120
116
  'executed': True,