/
Mobile.py
873 lines (702 loc) · 25.6 KB
/
Mobile.py
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
101
102
103
104
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
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
552
553
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
# -*- coding: utf-8 -*-
from robot.api import logger
from uiautomator import Device as d
import subprocess
import os
import time
import datetime
#from robot.output.monitor import CommandLineWriter as clm
from robot.libraries.BuiltIn import BuiltIn
import sys
#d = atx.connect()
# print "Importing Android library"
# clm = CommandLineWriter()
# clm.message("Importing Android library")
class TestHelper:
def __init__(self, adb):
self.adb = adb
def __convert_to_unicode_by_text(self, text):
"""
將輸入的字串轉換成 Unicode Transformation Format (UTF-8)
"""
# 由object轉換為string之後,移除前後的unicode標記,例如:將u'abc'轉換為字串abc
return repr(text)[2:-1]
def send_set_text_cmd(self, text):
"""
shell指令使用雙引號括起來,例如:adb shell "am broadcast -a myIME.intent.action.pass.string -e input abc"
但由於內容也可能為包含符號或是空白,所以必須再使用雙引號括起來,例如:"abc c"
"""
self.adb.shell_cmd('\"am broadcast -a myIME.intent.action.pass.string -e input \\\"\"%s\"\\\"\"' %
TestHelper.__convert_to_unicode_by_text(self, text))
self.adb.shell_cmd('input keyevent KEYCODE_UNKNOWN')
class ATX:
def __init__(self):
import atx
self.d = atx.connect()
def click_By_String(self, words):
self.d(text=words).click()
def clickImage(self, img):
self.d.click_image(img)
def assertImage(self, img):
if self.d.exists(img):
return True
else:
return False
class ADB:
def __init__(self, android_serial=None):
self.buf = []
self.buf.append('adb ')
self.prefix_cmd = ''.join(self.buf)
if android_serial is not None:
self.buf.append('-s %s ' % android_serial)
self.prefix_cmd = ''.join(self.buf)
def cmd(self, cmd):
"""
將 adb -s SERIAL_NUMBER xxxxxx or adb xxxxxxx 取代成 xxxxxx
"""
self.buf = []
self.buf.append(self.prefix_cmd)
self.buf.append(cmd)
cmd = ''.join(self.buf)
return subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
def shell_cmd(self, cmd):
"""
將 adb -s SERIAL_NUMBER shell xxxxxx or adb shell xxxxxxx 取代成 xxxxx-x
"""
self.buf = []
self.buf.append(self.prefix_cmd)
self.buf.append('shell ')
self.buf.append(cmd)
cmd = ''.join(self.buf)
return subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
class Mobile():
def __init__(self):
from uiautomator import device
self.device = device
def set_serial(self, android_serial):
"""
Specify given *android_serial* device to perform test.
You do not have to specify the device when there is only one device connects to the computer.
When you need to use multiple devices, do not use this keyword to switch between devices in test execution.
Using different library name when importing this library according to http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.8.4#setting-custom-name-to-test-library.
| ==Setting== | ==Value== | ==Value== | ==Value== |
| Library | Mobile | WITH NAME | Mobile1 |
| Library | Mobile | WITH NAME | Mobile2 |
And set the serial to each library.
| Test Case | Action | Argument |
| Multiple Devices | Mobile1.Set Serial | device_1's serial |
| | Mobile2.Set Serial | device_2's serial |
"""
self.adb = ADB(android_serial)
self.device = d(android_serial)
self.test_helper = TestHelper(self.adb)
def get_device_info(self):
"""
Retrieve the device info.
The keyword will return a dictionary.
You can log the information by using the log dictionary keyword in build in Collections library(http://robotframework.googlecode.com/hg/doc/libraries/Collections.html?r=2.8.4).
Example:
| ${device_info} | Get Device Info |
| Log Dictionary | ${device_info} |
=>
Dictionary size is 9 and it contains following items:\n
currentPackageName: com.android.keyguard\n
displayHeight: 1776\n
displayRotation: 0\n
displaySizeDpX: 360\n
displaySizeDpY: 640\n
displayWidth: 1080\n
naturalOrientation: True\n
productName: hammerhead\n
sdkInt: 19\n
Or get specific information of the device by giving the key.
| ${device_info} | Get Device Info | | |
| ${product_name} | Get From Dictionary | ${device_info} | productName |
=>
${product_name} = hammerhead
"""
return self.device.info
# Key Event Actions of the device
"""
Turn on/off screen
"""
def turn_on_screen(self):
"""
Turn on screen
"""
self.device.screen.on()
def turn_off_screen(self):
"""
Turn off screen
"""
self.device.screen.off()
"""
Press hard/soft key
"""
def press_key(self, *keys):
"""
Press *key* keycode.
You can find all keycode in http://developer.android.com/reference/android/view/KeyEvent.html
"""
#not tested
self.device.press(*keys)
def press_home(self):
"""
Press home key
"""
self.device.press.home()
def press_back(self):
"""
Press back key
"""
self.device.press.back()
def press_left(self):
"""
Press left key
"""
self.device.pres.left()
def press_right(self):
"""
Press right key
"""
self.device.press.right()
def press_up(self):
"""
Press up key
"""
self.device.press.up()
def press_down(self):
"""
Press down key
"""
self.device.press.down()
def press_center(self):
"""
Press center key
"""
self.device.press.center()
def press_menu(self):
"""
Press menu key
"""
self.device.press.menu()
def press_search(self):
"""
Press search key
"""
self.device.press.search()
def press_enter(self):
"""
Press enter key
"""
self.device.press.enter()
def press_delete(self):
"""
Press delete key
"""
self.device.press.delete()
def press_recent(self):
"""
Press recent key
"""
self.device.press.recent()
def press_volume_up(self):
"""
Press volume up key
"""
self.device.press.volume_up()
def press_volume_down(self):
"""
Press volume down key
"""
self.device.press.volume_down()
def press_camera(self):
"""
Press camera key
"""
self.device.press.camera()
def press_power(self):
"""
Press power key
"""
self.device.press.power()
# Gesture interaction of the device
def click_at_coordinates(self, x, y):
"""
Click at (x,y) coordinates.
"""
self.device.click(x, y)
def swipe_by_coordinates(self, sx, sy, ex, ey, steps=10):
"""
Swipe from (sx, sy) to (ex, ey) with *steps* .
Example:
| Swipe By Coordinates | 540 | 1340 | 940 | 1340 | | # Swipe from (540, 1340) to (940, 100) with default steps 10 |
| Swipe By Coordinates | 540 | 1340 | 940 | 1340 | 100 | # Swipe from (540, 1340) to (940, 100) with steps 100 |
"""
self.device.swipe(sx, sy, ex, ey, steps)
# Swipe from the center of the ui object to its edge
def swipe_left(self, steps=10, *args, **selectors):
"""
Swipe the UI object with *selectors* from center to left.
Example:
| Swipe Left | description=Home screen 3 | | # swipe the UI object left |
| Swipe Left | 5 | description=Home screen 3 | # swipe the UI object left with steps=5 |
See `introduction` for details about identified UI object.
"""
self.device(**selectors).swipe.left(steps=steps)
def swipe_right(self, steps=10, *args, **selectors):
"""
Swipe the UI object with *selectors* from center to right
See `Swipe Left` for more details.
"""
self.device(**selectors).swipe.right(steps=steps)
def swipe_top(self, steps=10, *args, **selectors):
"""
Swipe the UI object with *selectors* from center to top
See `Swipe Left` for more details.
"""
self.device(**selectors).swipe.up(steps=steps)
def swipe_bottom(self, steps=10, *args, **selectors):
"""
Swipe the UI object with *selectors* from center to bottom
See `Swipe Left` for more details.
"""
self.device(**selectors).swipe.down(steps=steps)
def object_swipe_left(self, obj, steps=10):
"""
Swipe the *obj* from center to left
Example:
| ${object} | Get Object | description=Home screen 3 | # Get the UI object |
| Object Swipe Left | ${object} | | # Swipe the UI object left |
| Object Swipe Left | ${object} | 5 | # Swipe the UI object left with steps=5 |
| Object Swipe Left | ${object} | steps=5 | # Swipe the UI object left with steps=5 |
See `introduction` for details about identified UI object.
"""
obj.swipe.left(steps=steps)
def object_swipe_right(self, obj, steps=10):
"""
Swipe the *obj* from center to right
See `Object Swipe Left` for more details.
"""
obj.swipe.right(steps=steps)
def object_swipe_top(self, obj, steps=10):
"""
Swipe the *obj* from center to top
See `Object Swipe Left` for more details.
"""
obj.swipe.up(steps=steps)
def object_swipe_bottom(self, obj, steps=10):
"""
Swipe the *obj* from center to bottom
See `Object Swipe Left` for more details.
"""
obj.swipe.down(steps=steps)
def drag_by_coordinates(self, sx, sy, ex, ey, steps=10):
"""
Drag from (sx, sy) to (ex, ey) with steps
See `Swipe By Coordinates` also.
"""
self.device.drag(sx, sy, ex, ey, steps)
# Wait until the specific ui object appears or gone
# wait until the ui object appears
def wait_for_exists(self, timeout=0, *args, **selectors):
"""
true means the object which has *selectors* exist
false means the object does not exist
in the given timeout
"""
return self.device(**selectors).wait.exists(timeout=timeout)
# wait until the ui object gone
def wait_until_gone(self, timeout=0, *args, **selectors):
"""
true means the object which has *selectors* disappear
false means the object exist
in the given timeout
"""
return self.device(**selectors).wait.gone(timeout=timeout)
def wait_for_object_exists(self, obj, timeout=0):
"""
true means the object exist
false means the object does not exist
in the given timeout
"""
return obj.wait.exists(timeout=timeout)
# wait until the ui object gone
def wait_until_object_gone(self, obj, timeout=0):
"""
true means the object disappear
false means the object exist
in the given timeout
"""
return obj.wait.gone(timeout=timeout)
# Perform fling on the specific ui object(scrollable)
def fling_forward_horizontally(self, *args, **selectors):
"""
return whether the object can be fling or not
"""
return self.device(**selectors).fling.horiz.forward()
def fling_backward_horizontally(self, *args, **selectors):
"""
return whether the object can be fling or not
"""
return self.device(**selectors).fling.horiz.backward()
def fling_forward_vertically(self, *args, **selectors):
"""
return whether the object can be fling or not
"""
return self.device(**selectors).fling.vert.forward()
def fling_backward_vertically(self, *args, **selectors):
"""
return whether the object can be fling or not
"""
return self.device(**selectors).fling.vert.backward()
# Perform scroll on the specific ui object(scrollable)
def scroll_to_beginning_vertically(self, steps=10, **selectors):
"""
"""
return self.device(**selectors).scroll.vert.toBeginning(steps=steps)
def scroll_to_end_vertically(self, steps=10, **selectors):
"""
"""
return self.device(**selectors).scroll.vert.toEnd(steps=steps)
def scroll_object_to_beginning_vertically(self, obj, steps=10):
"""
"""
return obj.scroll.vert.toBeginning(steps=steps)
def scroll_object_to_end_vertically(self, obj, steps=10):
"""
"""
return obj.scroll.vert.toEnd(steps=steps)
def scroll_forward_horizontally(self, obj, steps=10):
"""
return whether the object can be scroll or not
"""
return obj.scroll.horiz.forward(steps=steps)
def scroll_backward_horizontally(self, obj, steps=10):
"""
return whether the object can be scroll or not
"""
return obj.scroll.horiz.backward(steps=steps)
def scroll_to_horizontally(self, obj, *args, **selectors):
"""
return whether the object can be scroll or not
"""
return obj.scroll.horiz.to(**selectors)
def scroll_forward_vertically(self, obj, steps=10):
"""
return whether the object can be scroll or not
"""
return obj.scroll.vert.forward(steps=steps)
def scroll_backward_vertically(self, obj, steps=10):
"""
return whether the object can be scroll or not
"""
return obj.scroll.vert.backward(steps=steps)
def scroll_to_vertically(self, obj, *args, **selectors):
"""
return whether the object exists or not
"""
return obj.scroll.vert.to(**selectors)
# Screen Actions of the device
def get_screen_orientation(self):
"""
Get the screen orientation.
Possible result: natural, left, right, upsidedown
See for more details: https://github.com/xiaocong/uiautomator#screen-actions-of-the-device
"""
return self.device.orientation
def set_screen_orientation(self, orientation):
"""
Set the screen orientation.
Input *orientation* : natural or n, left or l, right or r, upsidedown (support android version above 4.3)
The keyword will unfreeze the screen rotation first.
See for more details: https://github.com/xiaocong/uiautomator#screen-actions-of-the-device
Example:
| Set Screen Orientation | n | # Set orientation to natural |
| Set Screen Orientation | natural | # Do the same thing |
"""
self.device.orientation = orientation
def freeze_screen_rotation(self):
"""
Freeze the screen auto rotation
"""
self.device.freeze_rotation()
def unfreeze_screen_rotation(self):
"""
Un-Freeze the screen auto rotation
"""
self.device.freeze_rotation(False)
def screenshot(self, scale=None, quality=None):
"""
Take a screenshot of device and log in the report with timestamp, scale for screenshot size and quality for screenshot quality
default scale=1.0 quality=100
"""
output_dir = BuiltIn().get_variable_value('${OUTPUTDIR}')
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y%m%d%H%M%S')
screenshot_path = '%s%s%s.png' % (output_dir, os.sep, st)
self.device.screenshot(screenshot_path, scale, quality)
logger.info('\n<a href="%s">%s</a><br><img src="%s">' %
(screenshot_path, st, screenshot_path), html=True)
# Watcher
# def register_click_watcher(self, watcher_name, selectors, *condition_list):
# """
# The watcher click on the object which has the selectors when conditions match
# """
# print type(selectors)
# watcher = self.device.watcher(watcher_name)
# for condition in condition_list:
# watcher.when(**condition)
# watcher.click(**selectors)
# self.device.watchers.run()
# print 'register watcher:%s' % watcher_name
# return
def __unicode_to_dict(self, a_unicode):
a_dict = dict()
dict_item_count = a_unicode.count('=')
for count in range(dict_item_count):
equal_sign_position = a_unicode.find('=')
comma_position = a_unicode.find(',')
a_key = a_unicode[0:equal_sign_position]
if comma_position == -1:
a_value = a_unicode[equal_sign_position + 1:]
else:
a_value = a_unicode[equal_sign_position + 1:comma_position]
a_unicode = a_unicode[comma_position + 1:]
a_dict[a_key] = a_value
return a_dict
def register_click_watcher(self, watcher_name, selectors, *condition_list):
"""
The watcher click on the object which has the *selectors* when conditions match
"""
watcher = self.device.watcher(watcher_name)
for condition in condition_list:
watcher.when(**self.__unicode_to_dict(condition))
watcher.click(**self.__unicode_to_dict(selectors))
self.device.watchers.run()
def register_press_watcher(self, watcher_name, press_keys, *condition_list):
"""
The watcher perform *press_keys* action sequentially when conditions match
"""
def unicode_to_list(a_unicode):
a_list = list()
comma_count = a_unicode.count(',')
for count in range(comma_count + 1):
comma_position = a_unicode.find(',')
if comma_position == -1:
a_list.append(str(a_unicode))
else:
a_list.append(a_unicode[0:comma_position])
a_unicode = a_unicode[comma_position + 1:]
return a_list
watcher = self.device.watcher(watcher_name)
for condition in condition_list:
watcher.when(**self.__unicode_to_dict(condition))
watcher.press(*unicode_to_list(press_keys))
self.device.watchers.run()
def remove_watchers(self, watcher_name=None):
"""
Remove watcher with *watcher_name* or remove all watchers
"""
if watcher_name == None:
self.device.watchers.remove()
else:
self.device.watchers.remove(watcher_name)
def list_all_watchers(self):
"""
Return the watcher list
"""
return self.device.watchers
# Selector
def get_object(self, *args, **selectors):
"""
Get the UI object with selectors *selectors*
See `introduction` for details about identified UI object.
"""
return self.device(*args, **selectors)
def get_count(self, *args, **selectors):
"""
Return the count of UI object with *selectors*
Example:
| ${count} | Get Count | text=Accessibility | # Get the count of UI object text=Accessibility |
| ${accessibility_text} | Get Object | text=Accessibility | # These two keywords combination |
| ${count} | Get Count Of Object | ${accessibility_text} | # do the same thing. |
"""
obj = self.get_object(**selectors)
return self.get_count_of_object(obj)
def get_count_of_object(self, obj):
"""
Return the count of given UI object
See `Get Count` for more details.
"""
return len(obj)
def get_info_of_object(self, obj, selector=None):
"""
return info dictionary of the *obj*
The info example:
{
u'contentDescription': u'',
u'checked': False,
u'scrollable': True,
u'text': u'',
u'packageName': u'com.android.launcher',
u'selected': False,
u'enabled': True,
u'bounds':
{
u'top': 231,
u'left': 0,
u'right': 1080,
u'bottom': 1776
},
u'className': u'android.view.View',
u'focusable': False,
u'focused': False,
u'clickable': False,
u'checkable': False,
u'chileCount': 1,
u'longClickable': False,
u'visibleBounds':
{
u'top': 231,
u'left': 0,
u'right': 1080,
u'bottom': 1776
}
}
"""
if selector:
return obj.info.get(selector)
else:
return obj.info
def click(self, *args, **selectors):
"""
click on the UI object with *selectors*
"""
self.device(**selectors).click()
def long_click(self, *args, **selectors):
"""
click on the UI object with *selectors*
"""
self.device(**selectors).long_click()
def call(self, obj, method, *args, **selectors):
"""
This keyword can use object method from original python uiautomator
See more details from https://github.com/xiaocong/uiautomator
Example:
| ${accessibility_text} | Get Object | text=Accessibility | # Get the UI object |
| Call | ${accessibility_text} | click | # Call the method of the UI object 'click' |
"""
func = getattr(obj, method)
return func(**selectors)
def set_text(self, input_text, *args, **selectors):
"""
Set *input_text* to the UI object with *selectors*
"""
self.device(**selectors).set_text(input_text)
# Other feature
def clear_text(self, *args, **selectors):
"""
Clear text of the UI object with *selectors*
"""
while True:
target = self.device(**selectors)
text = target.info['text']
target.clear_text()
remain_text = target.info['text']
if text == '' or remain_text == text:
break
def open_notification(self):
"""
open notification
Built in support for Android 4.3 (API level 18)
Using swipe action as a workaround for API level lower than 18
"""
sdk_version = self.device.info['sdkInt']
if sdk_version < 18:
height = self.device.info['displayHeight']
self.device.swipe(1, 1, 1, height - 1, 1)
else:
self.device.open.notification()
def open_quick_settings(self):
"""
open quick settings
Work for Android 4.3 above (API level 18)
"""
self.device.open.quick_settings()
def sleep(self, time):
"""
Sleep(no action) for *time* (in millisecond)
"""
target = 'wait for %s' % str(time)
self.device(text=target).wait.exists(timeout=time)
def install(self, apk_path):
"""
Install apk to the device
"""
self.adb.cmd('install "%s"' % apk_path)
def uninstall(self, package_name):
"""
Uninstall the APP with *package_name*
"""
self.adb.cmd('uninstall %s' % package_name)
def execute_adb_command(self, cmd):
"""
Execute adb *cmd*
"""
return self.adb.cmd(cmd)
def execute_adb_shell_command(self, cmd):
"""
Execute adb shell *cmd*
"""
return self.adb.shell_cmd(cmd)
def type(self, input_text, **selectors):
"""
Type *text* at current focused UI object
"""
self.test_helper.send_set_text_cmd(input_text)
def start_test_agent(self):
"""
[Test Agent]
Start Test Agent Service
"""
cmd = 'am start edu.ntut.csie.sslab1321.testagent/edu.ntut.csie.sslab1321.testagent.DummyActivity'
self.adb.shell_cmd(cmd)
def stop_test_agent(self):
"""
[Test Agent]
Stop Test Agent Service
"""
cmd = 'am broadcast -a testagent -e action STOP_TESTAGENT'
self.adb.shell_cmd(cmd)
def connect_to_wifi(self, ssid, password):
"""
[Test Agent]
Connect to *ssid* with *password*
"""
cmd = 'adb shell am start edu.ntut.csie.sslab1321.testagent/edu.ntut.csie.sslab1321.testagent.DummyActivity'
cmd = 'adb shell am broadcast -a testagent -e action CONNECT_TO_WIFI -e ssid WEP -e password 12345'
cmd = 'am broadcast -a testagent -e action CONNECT_TO_WIFI -e ssid %s -e password %s' % (
ssid, password)
self.adb.shell_cmd(cmd)
def clear_connected_wifi(self):
"""
[Test Agent]
Clear all existed Wi-Fi connection
"""
cmd = 'am broadcast -a testagent -e action CLEAR_CONNECTED_WIFIS'
self.adb.shell_cmd(cmd)
def foo(self):
pass
# logger.info('\nGot arg %s %s' % (output_dir, st), also_console=True)
# clm = CommandLineWriter()
# output some messages on console
# clm.message(' ')
# clm.message(u'中文')
# clm.message(u'2----------2')
def test(self):
pass
if __name__ == '__main__':
print 'start'
m = Mobile()
print 'end'