(八)微信与H5的测试

来源:互联网 发布:解析度分析软件 编辑:程序博客网 时间:2024/06/15 15:11

webview   :   WEBVIEW_com.tencent.mm:tools


实例:

import timefrom appium import webdriverdesired_caps = {}desired_caps['platformName'] = 'Android'desired_caps['platformVersion'] = '5.1.2'desired_caps['deviceName'] = 'MI 3'desired_caps['appPackage'] = 'com.tencent.mm'desired_caps['appActivity'] = 'com.tencent.mm.ui.LauncherUI'desired_caps['chromeOptions']={'androidProcess': 'com.tencent.mm:tools'}driver = webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)time.sleep(10)try:driver.find_element_by_xpath("//android.widget.FrameLayout/android.widget.LinearLayout[1]/android.widget.RelativeLayout[1]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[1]").click()time.sleep(2)driver.find_element_by_xpath("//android.widget.ListView[@resource-id=\"com.tencent.mm:id/bld\"]/android.widget.LinearLayout[1]").click()# print driver.contextstime.sleep(5)driver.find_element_by_xpath("//android.widget.ListView[@resource-id=\"com.tencent.mm:id/a2i\"]/android.widget.RelativeLayout[2]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[2]/android.widget.FrameLayout[1]").click()time.sleep(10)driver.switch_to.context(u'WEBVIEW_com.tencent.mm:tools')print driver.current_contexttime.sleep(2)driver.find_element_by_xpath("//*[@id=\"vue\"]/div[1]/div[1]/div/div/div/div[2]/a[2]").click()print "huk"time.sleep(10)# print driver.getContextHandles()# driver.find_element_by_xpath("//android.widget.LinearLayout/android.widget.RelativeLayout[2]").click()# time.sleep(3)# driver.find_element_by_id("com.tencent.mm:id/i0").click()except Exception, e:driver.quit()driver.quit()


题外话:

一般webview的元素获取版本都是debug版本,这样浏览器才能识别

需要浏览器能够翻墙,不然就是一个空白

0 0
原创粉丝点击