本文整理汇总了Python中uiautomatorplug.android.device.start_activity函数的典型用法代码示例。如果您正苦于以下问题:Python start_activity函数的具体用法?Python start_activity怎么用?Python start_activity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了start_activity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testVisitWebPage4G
def testVisitWebPage4G(self):
# turn off wifi
self._setWifistatus('off')
d.sleep(3)
#Launch Browser
self._launchBrowser()
# visite webpage
d(resourceId = 'com.android.browser:id/url', text = '输入网址').set_text(TOP5[3])
d.press('enter')
d.expect(CHECK_POINT[3], timeout=15)
# browse webpage
d.swipe(1000,1300,1000,600,10)
d.sleep(1)
d.swipe(1000,1300,1000,600,10)
d.sleep(1)
d.swipe(1000,600,1000,1300,10)
d.sleep(1)
d.swipe(1000,600,1000,1300,10)
d.sleep(1)
# turn on wifi
self._setWifistatus('on')
d.start_activity(component='com.android.browser/.BrowserActivity')
assert d(resourceId = 'com.android.browser:id/switch_btn').wait.exists(timeout = 5000),'Launch browser failed in 5s!'
示例2: testGame
def testGame(self):
#Launch DiTiePaoKu
d.start_activity(component='com.kiloo.subwaysurf/.RRAndroidPluginActivity')
assert d(packageName = 'com.kiloo.subwaysurf').wait.exists(timeout = 5000),'Launch game failed in 5s!'
d.sleep(10)
if d(text = '地铁跑酷正试图发送短信').exists:
d(text = '允许').click.wait()
if d(text = '地铁跑酷正试图获取位置信息').exists:
d(text = '允许').click.wait()
if d(text = '免费礼包大派送').exists:
d(text = '7天内不再显示').click.wait()
d(text = '暂不领取').click.wait()
if d(text = '提示').exists:
d(text = '取消').click.wait()
if d(className = 'android.widget.TextView').exists:
d(className = 'android.widget.TextView').click.wait()
#Click screen to start game
d.click(300,1540)
d.sleep(4)
for i in range(900):
direction = random.choice(['left','right','up','down'])
step = random.randint(2,20)
self._swipeGame(direction,step)
d.sleep(1)
#Exit game
d.press('back')
d.sleep(1)
d.click(150,1800)
d.sleep(1)
d.click(700,1100)
d.sleep(1)
示例3: testPlayStreamingVideo
def testPlayStreamingVideo(self):
#Start Browser
d.start_activity(component='com.android.browser/.BrowserActivity')
assert d(resourceId = 'com.android.browser:id/switch_btn').wait.exists(timeout = 5000),'Launch browser failed in 5s!'
d(resourceId = 'com.android.browser:id/newtab_btn').click.wait()
# input download audio url
d(resourceId = 'com.android.browser:id/url', text = '输入网址').set_text('auto.smartisan.com/media/Auto_Test_Video.mp4')
d.press('enter')
# play without element on webpage
# d.sleep(10)
# #d.click('Streaming_Play.png')
# d.click(540,960)
# #d(description = '播放').click.wait()
# assert d(description = '网页视图').wait.exists(timeout = 15000),'Loading streaming video failed in 15s!'
# # play time
# d.sleep(15)
# #assert d(description = '媒体控件').wait.exists(timeout = 10000),'Switch to webview failed in 10s!'
# if d.orientation != 'natural':
# d.orientation = 'n'
#play with element on webpage
assert d(description = '播放').wait.exists(timeout = 20000),'Loading webpage failed in 20s!'
d(description = '播放').click.wait()
assert d(description = '视频').wait.exists(timeout = 10000),'Start playing streaming video failed in 10s!'
d.sleep(10)
示例4: testSetTheme
def testSetTheme(self):
u.launchSettings()
u.selectOption('主题、壁纸、图标')
assert d(resourceId = 'smartisanos:id/tv_title',text = '主题、壁纸、图标').wait.exists(timeout = 5000),'Switch to theme view failed in 5s!'
u.selectOption('桌面主题')
assert d(resourceId = 'com.smartisanos.launcher:id/tv_title',text = '桌面主题').wait.exists(timeout = 5000),'Switch to theme view failed in 5s!'
for theme in THEME_LIST:
# if theme == '经典':
# u.selectOption(theme)
# assert d(resourceId = 'smartisanos:id/tv_title',text = theme).wait.exists(timeout = 5000),'Switch to theme thumbnail failed in 5s!'
# d(text = '设定').click.wait()
# if d(text = '桌面主题').wait.exists(timeout = 5000):
# continue
# else:
# assert d(resourceId = 'com.smartisanos.launcher:id/glview').wait.exists(timeout = 15000), 'Switch to launcher failed in 15s!'
#
if theme == '经典':
d(resourceId = 'com.smartisanos.launcher:id/list_theme').swipe.down()
d(resourceId = 'com.smartisanos.launcher:id/list_theme').swipe.down()
d(resourceId = 'com.smartisanos.launcher:id/list_theme').swipe.down()
d.sleep(1)
u.selectOption(theme)
assert d(resourceId = 'smartisanos:id/tv_title',text = theme).wait.exists(timeout = 5000),'Switch to theme thumbnail failed in 5s!'
d(text = '设定').click.wait()
assert d(text = '正在加载主题').wait.exists(timeout = 5000),'Loading theme view does not show up in 5s!'
assert d(text = '正在加载主题').wait.gone(timeout = 10000),'Loading theme view does not disappeared in 10s!'
assert d(resourceId = 'com.smartisanos.launcher:id/glview').wait.exists(timeout = 5000), 'Switch to launcher failed in 5s!'
d.sleep(3)
# exit theme setting
d.start_activity(component='com.android.settings/.Settings')
d.sleep(1)
示例5: setUp
def setUp(self):
u.setUp()
#Launch music player
d.start_activity(component='com.smartisanos.music/.activities.MusicMain')
assert d(resourceId = 'com.smartisanos.music:id/ib_right').wait.exists(timeout=5000),'Launch music player failed in 5s!'
d(text = '歌曲',resourceId = 'com.smartisanos.music:id/rb_song').click.wait()
assert d(resourceId = 'com.smartisanos.music:id/tv_title',text = '歌曲').wait.exists(timeout = 5000),'Switch to music list failed in 5s!'
示例6: testTurnOnOffWifi
def testTurnOnOffWifi(self):
'''
before running, keep wi-fi connected.
'''
#Launch Setting
d.start_activity(component='com.android.settings/.Settings')
assert d(text = '设置').wait.exists(timeout = 5000),'Launch settings failed in 5s!'
u.selectOption('无线网络')
assert d(resourceId = 'smartisanos:id/tv_title',text = '无线网络').wait.exists(timeout = 5000),'Switch to WIFI failed in 5s!'
if d(text = '要查看可用网络,请打开无线网络').exists:
print 'Current wifi status: Off'
d(resourceId = 'com.android.settings:id/item_switch').swipe.right(steps = 5)
d(text = '已连接').wait.exists(timeout = 15000)
else:
print 'Current wifi status: On'
d(text = '已连接').wait.exists(timeout = 15000)
for i in range(1000):
#Turn off wifi
d(resourceId = 'com.android.settings:id/item_switch').swipe.left(steps = 5)
assert d(text = '要查看可用网络,请打开无线网络').wait.exists(timeout = 15000),'Turn off wifi failed in 5s!'
#Turn on wifi
d(resourceId = 'com.android.settings:id/item_switch').swipe.right(steps = 5)
assert d(text = '已连接').wait.exists(timeout = 15000),'Turn on wifi failed in 5s!(UI)'
assert self._getWifiStatus(),'Turn on wifi failed in 5s!(Dumpsys)'
示例7: launchGallery
def launchGallery(self):
d.start_activity(component = ACTIVITY_NAME)
if d(text = 'Camera Roll').wait.exists(timeout = 3000):
d(text = 'Camera Roll').click.wait()
d(text = 'Albums').click.wait()
self.setMenuOptions('Sort by name, A-Z')
time.sleep(1) #Switch filter may take a few seconds
示例8: testWifiOpenAndClose
def testWifiOpenAndClose(self):
d.start_activity('--activity-clear-task', component='com.android.settings/.Settings')
d(text="无线和网络").wait.exists(timeout=2000)
#d(className="android.widget.ListView", resourceId="android:id/list").child(text='WLAN').click.wait()
#d(text="WLAN").click.wait()
d.press('enter')
d(resourceId='android:id/action_bar').child(text='WLAN').wait.exists(timeout=3000)
if d(className='android.widget.Switch', text='打开').exists:
d.press('right')
d.sleep(2)
d.press('up')
d.sleep(2)
for i in xrange(10):
d.press('enter')
assert d(resourceId='android:id/action_bar').child(text='关闭').wait.exists(timeout=3000), 'wifi close failed!'
d.press('enter')
assert d(resourceId='android:id/action_bar').child(text='打开').wait.exists(timeout=3000), 'wifi open failed!'
assert d(resourceId='android:id/list').child(text='已连接').wait.exists(timeout=20000), 'wifi connect failed!'
elif d(className='android.widget.Switch', text='关闭').exists:
d.press('right')
d.sleep(2)
d.press('up')
d.sleep(2)
for i in xrange(10):
d.press('enter')
assert d(resourceId='android:id/action_bar').child(text='打开').wait.exists(timeout=3000), 'wifi close failed!'
assert d(resourceId='android:id/list').child(text='已连接').wait.exists(timeout=20000), 'wifi connect failed!'
d.press('enter')
assert d(resourceId='android:id/action_bar').child(text='打开').wait.exists(timeout=3000), 'wifi open failed!'
示例9: testSaveNoteAsPic
def testSaveNoteAsPic(self):
# Launch Note
d.start_activity(component='com.smartisanos.notes/.NotesActivity')
if d(text = '列表').exists:
d(text = '列表').click.wait()
assert d(text = '便签').wait.exists(timeout = 5000),'Launch Note failed in 5s!'
for i in range(500):
d(resourceId = 'com.smartisanos.notes:id/add_button').click.wait()
assert d(resourceId = 'com.smartisanos.notes:id/delete_insert_button').wait.exists(timeout = 5000),'Switch to note editer failed in 5s!'
d(resourceId = 'com.smartisanos.notes:id/detail_note_editor').set_text('test content...')
d(resourceId = 'com.smartisanos.notes:id/delete_insert_button').click.wait()
d.sleep(1)
d.click(900,1830)
d.click('image.png')
# select first pic
d.click(150,370)
d.click('done.png')
assert d(resourceId = 'com.smartisanos.notes:id/detail_note_image').wait.exists(timeout = 5000),'Add pic to note failed in 5s!'
d(resourceId = 'com.smartisanos.notes:id/send_finish_button').click.wait()
d(resourceId = 'com.smartisanos.notes:id/send_finish_button').click.wait()
assert d(text = '请选择操作').wait.exists(timeout = 5000),'Share selector does not pop-up in 5s!'
d(text = '以图片形式分享').click.wait()
assert d(text = '保存图片').wait.exists(timeout = 5000),'Switch to thumbs failed in 5s!'
d(text = '取消').click.wait()
d(text = '列表').click.wait()
示例10: testShareNoteToWeibo
def testShareNoteToWeibo(self):
# Launch Note
d.start_activity(component='com.smartisanos.notes/.NotesActivity')
assert d(text = '便签').wait.exists(timeout = 5000),'Launch Note failed in 5s!'
for i in range(500):
d(resourceId = 'com.smartisanos.notes:id/add_button').click.wait()
assert d(resourceId = 'com.smartisanos.notes:id/delete_insert_button').wait.exists(timeout = 5000),'Switch to note editer failed in 5s!'
d(resourceId = 'com.smartisanos.notes:id/detail_note_editor').set_text('test content...')
d(resourceId = 'com.smartisanos.notes:id/delete_insert_button').click.wait()
d.sleep(1)
d.click(900,1830)
d.click('image.png')
# select first pic
d.click(150,370)
d.click('done.png')
assert d(resourceId = 'com.smartisanos.notes:id/detail_note_image').wait.exists(timeout = 5000),'Add pic to note failed in 5s!'
d(resourceId = 'com.smartisanos.notes:id/send_finish_button').click.wait()
d(resourceId = 'com.smartisanos.notes:id/send_finish_button').click.wait()
assert d(text = '请选择操作').wait.exists(timeout = 5000),'Share selector does not pop-up in 5s!'
d(text = '发送至新浪微博').click.wait()
#d(text = '生成长微博').click.wait()
#d(text = '保存到相册并继续').click.wait()
assert d(resourceId = 'com.smartisanos.notes:id/weibo_body_view').wait.exists(timeout = 5000),'Switch to Weibo proview failed in 5s!'
d(text = '下一步').click.wait()
assert d(text = '发送').wait.exists(timeout = 5000),'Prepare to send weibo failed in 5s!'
d(text = '取消').click.wait()
d(text = '取消').click.wait()
d(text = '列表').click.wait()
示例11: _switchLauncherSettings
def _switchLauncherSettings(self,viewmode):
# launch setting
d.start_activity(component='com.android.settings/.Settings')
assert d(text = '设置').wait.exists(timeout = 5000),'Launch settings failed in 5s!'
# get into launcher settings
if d(text = '单板块视图').wait.exists(timeout = 5000):
pass
else:
u.selectOption('桌面设置项')
assert d(text = '单板块视图').wait.exists(timeout = 5000),'Switch to Desktop Settings failed in 5s!'
if viewmode == '36' or viewmode == '81':
if d(text = '多板块视图').exists:
d(text = VIEW_MODE[viewmode]).click.wait()
if d(text = '设置桌面').wait.exists(timeout = 5000):
d(text = '确定').click.wait()
else:
d(text = '九宫格').click.wait()
d.sleep(3)
if d(text = '设置桌面').wait.exists(timeout = 5000):
d(text = '确定').click.wait()
d.sleep(3)
d.start_activity(component='com.android.settings/.Settings')
assert d(text = '设置').wait.exists(timeout = 5000),'Launch settings failed in 5s!'
d(text = VIEW_MODE[viewmode]).click.wait()
if d(text = '设置桌面').wait.exists(timeout = 5000):
d(text = '确定').click.wait()
else:
d(text = VIEW_MODE[viewmode]).click.wait()
if d(text = '设置桌面').wait.exists(timeout = 5000):
d(text = '确定').click.wait()
示例12: testSwitchLanguage
def testSwitchLanguage(self):
#language_dir = {'English':'Language',
# '中文 (简体)':'语言',
# '中文 (繁體)':'語言'
# }
d.start_activity(component='com.android.settings/.Settings')
assert d(text = '设置').wait.exists(timeout = 5000),'Launch settings failed in 5s!'
u.selectOption('语言和键盘')
assert d(text = '语言').wait.exists(timeout = 5000),'Switch to language setting failed in 5s!'
for i in range(50):
d(text = '语言').click.wait()
assert d(resourceId = 'smartisanos:id/tv_title',text = '语言').wait.exists(timeout = 5000),'Get into language setting failed in 5s!'
# switch to traditional chinese
d(text = '中文 (繁體)').click.wait()
assert d(text = '語言').wait.exists(timeout = 5000),'Switch to Traditional Chinese failed in 5s!'
d(text = '語言').click.wait()
assert d(resourceId = 'smartisanos:id/tv_title',text = '語言').wait.exists(timeout = 5000),'Get into language setting failed in 5s!'
# switch to english
d(text = 'English').click.wait()
assert d(text = 'Language').wait.exists(timeout = 5000),'Switch to English failed in 5s!'
d(text = 'Language').click.wait()
assert d(resourceId = 'smartisanos:id/tv_title',text = 'Language').wait.exists(timeout = 5000),'Get into language setting failed in 5s!'
# switch to simple chinese
d(text = '中文 (简体)').click.wait()
assert d(text = '语言').wait.exists(timeout = 5000),'Switch to English failed in 5s!'
示例13: testLaunchMultipleApp
def testLaunchMultipleApp(self):
# Launch an
for app in MULTIPLE_APP_LIST:
d.start_activity(component=app)
assert d(packageName=MULTIPLE_APP_LIST[app]).wait.exists(timeout=5000), "Launch %s failed in 5s" % app
d.sleep(5)
d.press("home")
d.sleep(1)
示例14: testLaunchMultipleApp
def testLaunchMultipleApp(self):
# Launch an
for app in MULTIPLE_APP_LIST:
d.start_activity(component= app)
assert d(resourceId = MULTIPLE_APP_LIST[app]).wait.exists(timeout = 5000),'Launch %s failed in 5s'%app
d.sleep(5)
d.press('home')
d.sleep(1)
示例15: _launchCamera
def _launchCamera(self):
d.start_activity(component = ACTIVITY_NAME)
#When it is the first time to launch camera there will be a dialog to ask user 'remember location', so need to check
if d(text = 'OK').wait.exists(timeout = 3000):
d(text = 'OK').click.wait()
if d(text = 'Skip').wait.exists(timeout = 3000):
d(text = 'Skip').click.wait()
assert d(resourceId = 'com.intel.camera22:id/mode_button').wait.exists(timeout = 3000), 'Launch camera failed in 3s'