├── .idea
├── .name
├── encodings.xml
├── iosMonkey.iml
├── misc.xml
├── modules.xml
├── vcs.xml
└── workspace.xml
├── README.md
├── mk_event
├── __init__.py
├── __init__.pyc
├── mk_bake.py
├── mk_bake.pyc
├── mk_content.py
├── mk_content.pyc
├── mk_home_key.py
├── mk_home_key.pyc
├── mk_launch.py
├── mk_launch.pyc
├── mk_share.py
├── mk_share.pyc
├── mk_submit.py
├── mk_submit.pyc
├── mk_swipe.py
├── mk_swipe.pyc
├── mk_tap.py
├── mk_tap.pyc
├── mk_tap_special_point.py
└── mk_tap_special_point.pyc
├── parameters
├── __init__.py
├── __init__.pyc
├── configure.py
├── configure.pyc
├── math_random.py
├── math_random.pyc
├── monkey.py
├── monkey.pyc
└── run_server.py
└── run.py
/.idea/.name:
--------------------------------------------------------------------------------
1 | iosMonkey
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/iosMonkey.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 | true
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 | Python
163 |
164 |
165 |
166 |
167 | PyTypeCheckerInspection
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 | 1491967983526
552 |
553 | 1491967983526
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 |
754 |
755 |
756 |
757 |
758 |
759 |
760 |
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 |
776 |
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 |
811 |
812 |
813 |
814 |
815 |
816 |
817 |
818 |
819 |
820 |
821 |
822 |
823 |
824 |
825 |
826 |
827 |
828 |
829 |
830 |
831 |
832 |
833 |
834 |
835 |
836 |
837 |
838 |
839 |
840 |
841 |
842 |
843 |
844 |
845 |
846 |
847 |
848 |
849 |
850 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
859 |
860 |
861 |
862 |
863 |
864 |
865 |
866 |
867 |
868 |
869 |
870 |
871 |
872 |
873 |
874 |
875 |
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 |
884 |
885 |
886 |
887 |
888 |
889 |
890 |
891 |
892 |
893 |
894 |
895 |
896 |
897 |
898 |
899 |
900 |
901 |
902 |
903 |
904 |
905 |
906 |
907 |
908 |
909 |
910 |
911 |
912 |
913 |
914 |
915 |
916 |
917 |
918 |
919 |
920 |
921 |
922 |
923 |
924 |
925 |
926 |
927 |
928 |
929 |
930 |
931 |
932 |
933 |
934 |
935 |
936 |
937 |
938 |
939 |
940 |
941 |
942 |
943 |
944 |
945 |
946 |
947 |
948 |
949 |
950 |
951 |
952 |
953 |
954 |
955 |
956 |
957 |
958 |
959 |
960 |
961 |
962 |
963 |
964 |
965 |
966 |
967 |
968 |
969 |
970 |
971 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **1,功能**
2 | 1.可以模拟android monkey执行的方式,在IOS APP页面点击 滑动操等作,支持 ios 9和ios10
3 | 2,支持一台ios执行
4 |
5 | **2,准备macaca环境**
6 | 安装usbmuxd
7 | ```
8 | $ brew install usbmuxd
9 | ```
10 | 安装iso-webkit-debug-proxy
11 | ```
12 | $ brew install ios-webkit-debug-proxy
13 | ```
14 | 安装iso-deploy
15 | ```
16 | $ npm i ios-deploy -g
17 | ```
18 | 安装macacajs包括,macaca-cli macaca-ios
19 | ```
20 | npm install macaca-cli -g
21 | EVELOPMENT_TEAM_ID=需要填写TeamID npm install macaca-ios -g
22 | ```
23 | 检测macaca环境,无报错
24 | ```
25 | $ macaca doctor
26 | ```
27 |
28 | **3,WebDriverAgent项目重签名**
29 | 安装app-inspector
30 | ```
31 | EVELOPMENT_TEAM_ID=需要填写TeamID npm install app-inspector -g
32 | ```
33 | 重签名参考帖子
34 | [app-inspector查看器](https://testerhome.com/topics/7202)
35 |
36 | **4,操作指南**
37 | 1,在iosMonkey/parameters/configure.py文件中设置udid/bundleId/port/proxy,port/proxy可以默认
38 | ```
39 | bundleId = 'com.bluecity.blued.qy'
40 | port = 3456
41 | proxy = 8900
42 | udid = 'bad980986e328c37e478edcc81c552d291ce4024'
43 | version = '10.2.1'
44 | ```
45 |
46 | 2,文件中可以修改事件的概率,概率相加应是100%
47 | ```
48 | TAP = 0.40
49 | SWIPE = 0.30
50 | BACK = 0.10
51 | SUBMIT = 0.05
52 | CONTENT = 0.05
53 | POINT = 0.05
54 | SHARE = 0.05
55 | ```
56 |
57 | 3,终端启动macaca服务
58 | ```
59 | $ macaca server --verbose
60 | ```
61 |
62 | 4,运行iosMonkey/run.py,开启无限事件测试之旅
63 | ```
64 | #######################################
65 | # #
66 | # 欢迎使用 Blued iosMonkey测试 #
67 | # #
68 | #######################################
69 |
70 | [INFO]---------------------------------------------------
71 | [INFO]测试设备: bad980986e328c37e478edcc81c552d291ce4024
72 | [INFO]测试App : com.bluecity.blued.qy
73 | [INFO]---------------------------------------------------
74 |
75 | [ RUN ] sending Event : Content->( 201 , 391 )
76 | [ RUN ] Event number: 1
77 | [ RUN ] sending Swipe Event : Swipe-> [start(302.0 , 653.0 ), end( 302.0 , 74.0)]
78 | [ RUN ] Event number: 2
79 | [ RUN ] sending Event : Submit->( 177 , 596 )
80 | [ RUN ] Event number: 3
81 | [ RUN ] sending Tap Event : Tap->( 303.0 , 376.0 )
82 | ```
83 |
--------------------------------------------------------------------------------
/mk_event/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mengdegong/iosMonkey/fea6ee638bf3f1ba3db45d2b60841e8f8c21b962/mk_event/__init__.py
--------------------------------------------------------------------------------
/mk_event/__init__.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mengdegong/iosMonkey/fea6ee638bf3f1ba3db45d2b60841e8f8c21b962/mk_event/__init__.pyc
--------------------------------------------------------------------------------
/mk_event/mk_bake.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | __author__ = 'mengdegong'
4 |
5 | import random
6 |
7 | def bake_event(driver,backX,backY):
8 | json = {}
9 | print '[ RUN ] sending Event : Back->( %s , %s )' %(backX,backY)
10 | json['x'] = backX
11 | json['y'] = backY
12 | driver.touch('tap',json)
13 | return True
14 |
15 |
--------------------------------------------------------------------------------
/mk_event/mk_bake.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mengdegong/iosMonkey/fea6ee638bf3f1ba3db45d2b60841e8f8c21b962/mk_event/mk_bake.pyc
--------------------------------------------------------------------------------
/mk_event/mk_content.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | __author__ = 'mengdegong'
4 |
5 | import random
6 |
7 | def content_event(driver, contentX_max, contentX_min, contentY_max, contentY_mim):
8 | json = {}
9 | x = random.randint(0,contentX_max) % (contentX_max - contentX_min + 1) + contentX_min
10 | y = random.randint(0,contentY_max) % (contentY_max - contentY_mim + 1) + contentY_mim
11 | print '[ RUN ] sending Event : Content->( %s , %s )' %(x, y)
12 | json['x'] = x
13 | json['y'] = y
14 | driver.touch('tap',json)
15 | return True
16 |
--------------------------------------------------------------------------------
/mk_event/mk_content.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mengdegong/iosMonkey/fea6ee638bf3f1ba3db45d2b60841e8f8c21b962/mk_event/mk_content.pyc
--------------------------------------------------------------------------------
/mk_event/mk_home_key.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | __author__ = 'mengdegong'
4 |
5 | import os,time,threading
6 |
7 | def home_event(driver, udid, bundleId):
8 | print '[ RUN ] sending HOMEKEY Event.'
9 | time.sleep(3)
10 | def Tread():
11 | driver.keys(u'\uE105')
12 | try:
13 | os.popen('pkill -9 idevicedebug')
14 | print '[ RUN ] idevicedebut stop'
15 | except Exception ,e:
16 | print '\n[ ERROR ] ' + str(e) + '\n'
17 |
18 | print '[ RUN ] launch App : ' + bundleId
19 | try:
20 | os.popen('idevicedebug -u %s run %s' %(udid, bundleId))
21 | time.sleep(3)
22 | return True
23 | except Exception ,e:
24 | print '\n[ ERROR ] ' + str(e) + '\n'
25 | t = threading.Thread(target=Tread)
26 | t.start()
27 | t.stop()
28 |
--------------------------------------------------------------------------------
/mk_event/mk_home_key.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mengdegong/iosMonkey/fea6ee638bf3f1ba3db45d2b60841e8f8c21b962/mk_event/mk_home_key.pyc
--------------------------------------------------------------------------------
/mk_event/mk_launch.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | __author__ = 'mengdegong'
4 |
5 | import os,time,threading
6 |
7 | def launch_event(driver, udid, bundleId):
8 | def Tread():
9 | print '[ RUN ] sending launch Event.'
10 | try:
11 | time.sleep(2)
12 | os.system('pkill -9 idevicedebug')
13 | print '[ RUN ] idevicedebut stop'
14 | except Exception ,e:
15 | print '\n[ ERROR ] '+str(e) + '\n'
16 | threading.Thread(target=Tread).start()
17 |
18 | print '[ RUN ] launch App : ' + bundleId
19 | try:
20 | os.system('idevicedebug -u %s run %s' %(udid, bundleId))
21 | time.sleep(3)
22 | return True
23 | except Exception ,e:
24 | print '\n[ ERROR ] '+str(e) + '\n'
25 |
--------------------------------------------------------------------------------
/mk_event/mk_launch.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mengdegong/iosMonkey/fea6ee638bf3f1ba3db45d2b60841e8f8c21b962/mk_event/mk_launch.pyc
--------------------------------------------------------------------------------
/mk_event/mk_share.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | __author__ = 'mengdegong'
4 |
5 | import random
6 |
7 | def share_event(driver, width):
8 | json = {}
9 | x = width / 10
10 | y = 25
11 | print '[ RUN ] sending Event : Share->( %s , %s )' %(x, y)
12 | json['x'] = x
13 | json['y'] = y
14 | driver.touch('tap',json)
15 | return True
--------------------------------------------------------------------------------
/mk_event/mk_share.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mengdegong/iosMonkey/fea6ee638bf3f1ba3db45d2b60841e8f8c21b962/mk_event/mk_share.pyc
--------------------------------------------------------------------------------
/mk_event/mk_submit.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | __author__ = 'mengdegong'
4 |
5 | import random
6 |
7 | #目测和mk_content一致
8 |
9 | def submit_event(driver, submitX_max, submitX_mim, submitY_max, submitY_mim):
10 | json = {}
11 | x = random.randint(0,submitX_max) % (submitX_max - submitX_mim + 1) + submitX_mim
12 | y = random.randint(0,submitY_max) % (submitY_max - submitY_mim + 1) + submitY_mim
13 | print '[ RUN ] sending Event : Submit->( %s , %s )' %(x, y)
14 | json['x'] = x
15 | json['y'] = y
16 | driver.touch('tap',json)
17 | return True
18 |
19 |
--------------------------------------------------------------------------------
/mk_event/mk_submit.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mengdegong/iosMonkey/fea6ee638bf3f1ba3db45d2b60841e8f8c21b962/mk_event/mk_submit.pyc
--------------------------------------------------------------------------------
/mk_event/mk_swipe.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | __author__ = 'mengdegong'
4 |
5 | import math,random
6 |
7 | def swipe_event(driver, width, height):
8 | json = {}
9 | startX = math.ceil(random.random() * (width - 1))
10 | startY = math.ceil(random.random() * (height - 1))
11 | entY = math.ceil(random.random() * (height - 1))
12 | print '[ RUN ] sending Swipe Event : Swipe-> [start(%s , %s ), end( %s , %s)]' %(startX, startY, startX, entY)
13 | json['fromX'] = startX
14 | json['fromY'] = startY
15 | json['toX'] = startX
16 | json['toY'] = entY
17 | json['duration'] = 1
18 | driver.touch('drag', json)
19 | return True
20 |
21 |
--------------------------------------------------------------------------------
/mk_event/mk_swipe.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mengdegong/iosMonkey/fea6ee638bf3f1ba3db45d2b60841e8f8c21b962/mk_event/mk_swipe.pyc
--------------------------------------------------------------------------------
/mk_event/mk_tap.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | __author__ = 'mengdegong'
4 |
5 | import math,random
6 |
7 | def tap_event(driver, width, height):
8 | json = {}
9 | x = math.ceil(random.random() * (width - 1))
10 | y = math.ceil(random.random() * (height - 1))
11 | print '[ RUN ] sending Tap Event : Tap->( %s , %s )' %(x,y)
12 | json['x'] = x
13 | json['y'] = y
14 | driver.touch('tap',json)
15 | return True
16 |
--------------------------------------------------------------------------------
/mk_event/mk_tap.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mengdegong/iosMonkey/fea6ee638bf3f1ba3db45d2b60841e8f8c21b962/mk_event/mk_tap.pyc
--------------------------------------------------------------------------------
/mk_event/mk_tap_special_point.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | __author__ = 'mengdegong'
4 |
5 | def tap_point_event(driver, special_point_x, special_point_y):
6 | json = {}
7 | print '[ RUN ] sending SpecialPoint Tap Event : Tap->( %s , %s )' %(special_point_x,special_point_y)
8 | json['x'] = special_point_x
9 | json['y'] = special_point_y
10 | driver.touch('tap',json)
11 | return True
12 |
--------------------------------------------------------------------------------
/mk_event/mk_tap_special_point.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mengdegong/iosMonkey/fea6ee638bf3f1ba3db45d2b60841e8f8c21b962/mk_event/mk_tap_special_point.pyc
--------------------------------------------------------------------------------
/parameters/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mengdegong/iosMonkey/fea6ee638bf3f1ba3db45d2b60841e8f8c21b962/parameters/__init__.py
--------------------------------------------------------------------------------
/parameters/__init__.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mengdegong/iosMonkey/fea6ee638bf3f1ba3db45d2b60841e8f8c21b962/parameters/__init__.pyc
--------------------------------------------------------------------------------
/parameters/configure.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | __author__ = 'mengdegong'
4 |
5 | '''
6 | 配置信息
7 | '''
8 | bundleId = 'com.blued.international'
9 | port = 3456
10 | proxy = 8900
11 | udid = '053288d1e59d03a3802b90237f01d53cc0d4378b'
12 | # udid = '37adc1f3a175fe056046dc239b68d28d96d47c2f'
13 | version = '10.3.2'
14 |
15 |
16 | '''
17 | 概率
18 | '''
19 | TAP = 0.40
20 | SWIPE = 0.30
21 | BACK = 0.10
22 | SUBMIT = 0.05
23 | CONTENT = 0.05
24 | POINT = 0.04
25 | SHARE = 0.04
26 | HOME = 0.2
27 |
--------------------------------------------------------------------------------
/parameters/configure.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mengdegong/iosMonkey/fea6ee638bf3f1ba3db45d2b60841e8f8c21b962/parameters/configure.pyc
--------------------------------------------------------------------------------
/parameters/math_random.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | __author__ = 'mengdegong'
4 |
5 | import random
6 | from configure import *
7 |
8 | class random_math():
9 | def __init__(self):
10 | self.EVENT_TYPE_TAP = TAP
11 | self.EVENT_TYPE_SWIPE = SWIPE
12 | self.EVENT_TYPE_BACK = BACK
13 | self.EVENT_TYPE_SUBMIT = SUBMIT
14 | self.EVENT_TYPE_CONTENT = CONTENT
15 | self.EVENT_TYPE_SPECIAL_POINT = POINT
16 | self.EVENT_TYPE_SHARE = SHARE
17 | self.EVENT_TYPE_HOME = HOME
18 |
19 | def percentage_random(self):
20 | random_number = random.random()
21 | if random_number >= 0 and random_number <= self.EVENT_TYPE_TAP:
22 | return 0
23 | elif random_number >= self.EVENT_TYPE_TAP and random_number <= self.EVENT_TYPE_TAP + self.EVENT_TYPE_SWIPE:
24 | return 1
25 | elif self.EVENT_TYPE_TAP + self.EVENT_TYPE_SWIPE <= random_number <= self.EVENT_TYPE_TAP + self.EVENT_TYPE_SWIPE + self.EVENT_TYPE_BACK:
26 | return 2
27 | elif self.EVENT_TYPE_TAP + self.EVENT_TYPE_SWIPE + self.EVENT_TYPE_BACK <= random_number <= self.EVENT_TYPE_TAP + self.EVENT_TYPE_SWIPE + self.EVENT_TYPE_BACK + self.EVENT_TYPE_SUBMIT:
28 | return 3
29 | elif self.EVENT_TYPE_TAP + self.EVENT_TYPE_SWIPE + self.EVENT_TYPE_BACK + self.EVENT_TYPE_SUBMIT <= random_number <= self.EVENT_TYPE_TAP + self.EVENT_TYPE_SWIPE + self.EVENT_TYPE_BACK + self.EVENT_TYPE_SUBMIT \
30 | + self.EVENT_TYPE_CONTENT:
31 | return 4
32 | elif self.EVENT_TYPE_TAP + self.EVENT_TYPE_SWIPE + self.EVENT_TYPE_BACK + self.EVENT_TYPE_SUBMIT + self.EVENT_TYPE_CONTENT <= random_number <= self.EVENT_TYPE_TAP + self.EVENT_TYPE_SWIPE + self.EVENT_TYPE_BACK + self.EVENT_TYPE_SUBMIT \
33 | + self.EVENT_TYPE_CONTENT + self.EVENT_TYPE_SPECIAL_POINT:
34 | return 5
35 | elif self.EVENT_TYPE_TAP + self.EVENT_TYPE_SWIPE + self.EVENT_TYPE_BACK + self.EVENT_TYPE_SUBMIT + self.EVENT_TYPE_CONTENT \
36 | + self.EVENT_TYPE_SPECIAL_POINT <= random_number <= self.EVENT_TYPE_TAP + self.EVENT_TYPE_SWIPE + self.EVENT_TYPE_BACK + self.EVENT_TYPE_SUBMIT \
37 | + self.EVENT_TYPE_CONTENT + self.EVENT_TYPE_SPECIAL_POINT + self.EVENT_TYPE_SHARE:
38 | return 6
39 | elif self.EVENT_TYPE_TAP + self.EVENT_TYPE_SWIPE + self.EVENT_TYPE_BACK + self.EVENT_TYPE_SUBMIT + self.EVENT_TYPE_CONTENT \
40 | + self.EVENT_TYPE_SPECIAL_POINT + self.EVENT_TYPE_SHARE <= random_number <= self.EVENT_TYPE_TAP + self.EVENT_TYPE_SWIPE + self.EVENT_TYPE_BACK + self.EVENT_TYPE_SUBMIT \
41 | + self.EVENT_TYPE_CONTENT + self.EVENT_TYPE_SPECIAL_POINT + self.EVENT_TYPE_SHARE + self.EVENT_TYPE_HOME:
42 | return 7
43 | return -1
44 |
--------------------------------------------------------------------------------
/parameters/math_random.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mengdegong/iosMonkey/fea6ee638bf3f1ba3db45d2b60841e8f8c21b962/parameters/math_random.pyc
--------------------------------------------------------------------------------
/parameters/monkey.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | __author__ = 'mengdegong'
4 |
5 | from macaca import WebDriver
6 | import configure
7 | from math_random import *
8 | from mk_event.mk_tap import *
9 | from mk_event.mk_swipe import *
10 | from mk_event.mk_submit import *
11 | from mk_event.mk_launch import *
12 | from mk_event.mk_home_key import *
13 | from mk_event.mk_content import *
14 | from mk_event.mk_bake import *
15 | from mk_event.mk_tap_special_point import *
16 | from mk_event.mk_share import *
17 | from parameters.run_server import *
18 |
19 | class monkey():
20 | def __init__(self):
21 | self.backX = 25
22 | self.backY = 40
23 |
24 | def info(self):
25 | print "\n "+"#######################################\n"+ \
26 | " # #\n"+ \
27 | " # 欢迎使用 Blued iosMonkey测试 #\n"+ \
28 | " # #\n"+ \
29 | " #######################################"
30 |
31 | print '\n[ INFO ]---------------------------------------------------'
32 | print '[ INFO ]测试设备: %s \n[ INFO ]测试App : %s' %(configure.udid,configure.bundleId)
33 | print '[ INFO ]---------------------------------------------------\n'
34 | os.system('pkill -9 proxy')
35 | os.system('pkill -9 node')
36 | try:
37 | r = RunServer(port)
38 | r.start()
39 | monkey().run_event()
40 | except Exception ,e:
41 | print "\n[ ERROR ]---------------------------------------------------\n" +\
42 | "[ ERROR ]"+str(e)+"\n"+\
43 | "[ ERROR ]---------------------------------------------------"
44 |
45 | def run_event(self):
46 | driver = monkey().start
47 | eventfun = 0
48 | width = driver.get_window_size().get('width')
49 | height = driver.get_window_size().get('height')
50 | submitX_max = width - 1
51 | submitX_mim = width / 10
52 | submitY_max = height - 1
53 | submitY_mim = height / 10 * 9
54 |
55 | contentX_max = width - width / 10
56 | contentX_mim = width / 10;
57 | contentY_max = height / 2 + height / 10
58 | contentY_mim = height / 2 - height / 10
59 |
60 | special_point_x = width / 2
61 | special_point_y = int(height * 0.94)
62 |
63 | while True:
64 | num = random_math().percentage_random()
65 | if num ==0:
66 | tap_event(driver, width, height)
67 |
68 | elif num ==1 :
69 | swipe_event(driver, width, height)
70 |
71 | elif num ==2 :
72 | bake_event(driver, self.backX, self.backY)
73 |
74 | elif num ==3 :
75 | submit_event(driver, submitX_max, submitX_mim, submitY_max, submitY_mim)
76 |
77 | elif num ==4 :
78 | content_event(driver, contentX_max, contentX_mim, contentY_max, contentY_mim)
79 |
80 | elif num == 5 :
81 | tap_point_event(driver, special_point_x, special_point_y)
82 |
83 | elif num == 6:
84 | share_event(driver, width)
85 | elif num == 7:
86 | home_event(driver, udid, bundleId)
87 |
88 | eventfun = eventfun + 1
89 | print '[ RUN ] Event number: %d ' %eventfun
90 |
91 |
92 | @property
93 | def start(self):
94 | porps = {}
95 | server = {}
96 |
97 | porps['platformName'] = 'iOS'
98 | porps['platformVersion'] = configure.version
99 | porps['deviceName'] = 'iPhone 6s'
100 | porps['autoAcceptAlerts'] = True
101 | porps['udid'] = configure.udid
102 | porps['bundleId'] = configure.bundleId
103 | # porps['proxyPort'] = configure.proxy
104 |
105 | server['hostname'] = '127.0.0.1'
106 | server['port'] = configure.port
107 |
108 | try:
109 | print porps
110 | print server
111 | self.driver = WebDriver(porps, server)
112 | self.driver.init()
113 | return self.driver
114 | except Exception ,e:
115 | print "\n[ ERROR ] ---------------------------------------------------" +\
116 | "\n[ ERROR ] macaca server 启动失败\n"+\
117 | "[ ERROR ] ---------------------------------------------------\n"
118 |
119 | # 守护进程
120 | # finally:
121 | # print '8888'
122 | # self.driver.init()
123 | # time.sleep(5)
124 | # monkey().run_event()
125 | # print '[ RUN ] 守护进程启动成功'
126 |
127 |
128 |
129 |
--------------------------------------------------------------------------------
/parameters/monkey.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mengdegong/iosMonkey/fea6ee638bf3f1ba3db45d2b60841e8f8c21b962/parameters/monkey.pyc
--------------------------------------------------------------------------------
/parameters/run_server.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: UTF-8 -*-
3 | __author__ = 'mengdegong'
4 |
5 | import threading
6 | import os
7 |
8 | class RunServer(threading.Thread):
9 | def __init__(self, port):
10 | threading.Thread.__init__(self)
11 | self.cmd = 'macaca server -p %s' % port
12 |
13 | def run(self):
14 | os.system(self.cmd)
--------------------------------------------------------------------------------
/run.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | __author__ = 'mengdegong'
4 |
5 | from parameters.monkey import monkey
6 |
7 | if __name__ == '__main__':
8 | a = monkey()
9 | a.info()
10 |
--------------------------------------------------------------------------------