app自动化测试之实战应用(百度app简单测试)

模拟在百度app中搜索python相关内容代码如下:

 

from appium import webdriver

desired_caps = {}
desired_caps['deviceName'] = '621QECQ23DKQP'
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '6.0'
desired_caps['appPackage'] = 'com.baidu.searchbox'
desired_caps['appActivity'] = '.SplashActivity'
#下面这个是百度二次启动的activity desired_caps['appWaitActivity'] = '.MainActivity' desired_caps['unicodeKeyboard'] = 'True' desired_caps['resetKeyboard'] = 'True' desired_caps['automationName'] = 'Selendroid' driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_caps)
#点击搜索框 driver.find_element_by_id('baidu_searchbox').click()
#在搜索框中输入python driver.find_element_by_id('SearchTextInput').send_keys('python')
#点击查询 driver.find_element_by_id('float_search_or_cancel').click() driver.quit()

 

这里多了一个参数项'appWaitActivity',如果对应的app是二次启动的话,需要加上这个,不然启动不了,用adb logcat中可以看到有俩个启动activity:

posted @ 2018-06-24 10:34  水里的芋头  阅读(322)  评论(0编辑  收藏  举报