Android WebView测试

Android WebView测试,第1张

概述混合应用中包含Web视图的应用,在Appium介绍及环境安装中介绍了appium支持WebView测试,本文将分享Android混合页面的测试方法。WebView测试环境准备手机端被测浏览器:iOS:SafariAndroid:Chrome,Chromium,Browser(自带浏览器)PC端安装Chrome浏览器(或chromium),可以访问

混合应用中包含 Web 视图的应用,在 Appium 介绍及环境安装 中介绍了appium支持WebVIEw测试,本文将分享AndroID 混合页面的测试方法。

WebVIEw测试环境准备手机端

被测浏览器:

iOS:Safari

AndroID:Chrome,Chromium,browser (自带浏览器)

PC端安装 Chrome浏览器(或chromium),可以访问https://www.google.com下载手机浏览器webvIEw版本对应的 driverwebvIEw和driver版本对应关系:https://raw.githubusercontent.com/appium/appium-chromedriver/master/config/mapping.jsondriver下载:https://sites.google.com/a/chromium.org/chromedriver/downloads国内镜像地址 : https://npm.taobao.org/mirrors/chromedriver/appium github: https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/web/chromedriver.md查看手机浏览器版本
adb shell pm List package | grep webvIEwadb shell pm dump com.androID.browser | grep versionadb shell pm dump com.androID.Chrome | grep versionadb shell pm dump com.androID.webvIEw | grep version

查看手机browser和Chrome版本

C:\Users287>adb shell pm List packages|findstr browserpackage:com.androID.browserC:\Users287>adb shell pm dump com.androID.browser | findstr version      versionCode=22 targetSdk=22      versionname=5.1.1-500200323C:\Users287>adb shell pm dump com.androID.Chrome | findstr version      versionCode=398713200 targetSdk=29      versionname=80.0.3987.132            enabled=true targetSdkVersion=29 versionCode=398713200
查看手机webvIEw版本

在手机上设置中查看 AndroID System WebVIEw应用版本

客户端代码

desirecapability

“ChromedriverExecutable" = "指定driver地址”"browser" = "browser" 或者“browser" = ”Chrome“WebVIEw元素定位

1、连接手机/模拟器

手机打开Google浏览器,并进入百度网页:https://m.baidu.com

2、Chrome浏览器输入地址: chrome://inspect

可以看到电脑连接的设备名以及打开的手机浏览器

点击inspect

这样就可以定位到浏览器元素。

AndroID混合页面测试

文档:https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews?hl=zh-cn

测试步骤:

打开APIDemos进入WebVIEw页面点击"i am a link"退出应用

下载APIDemos-deBUG.apk

https://github.com/appium/appium/blob/master/sample-code/apps/ApiDemos-debug.apk
from appium import webdriverfrom appium.webdriver.common.mobileby import MobileByclass Testbrowser():    def setup(self):        desired_caps = {        'platformname': 'androID',                'platformVersion': '10',        'appPackage': 'io.appium.androID.APIs',        'appActivity': 'io.appium.androID.APIs.APIDemos',                'devicename': 'CUYDU19626004019',        'noreset': 'true',        'ChromedriverExecutable': 'D:/testing_tools/Chromedriver85/chromedriver.exe'        }        self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)        self.driver.implicitly_wait(5)            def teardown(self):                self.driver.quit()            def test_webvIEw(self):        self.driver.find_element_by_accessibility_ID("VIEws").click()        webvIEw ="WebVIEw"        print(self.driver.contexts)        self.driver.find_element_by_androID_uiautomator('new UiScrollable(new UiSelector().'                                                        'scrollable(true).instance(0)).'                                                        f'scrollintoVIEw(new UiSelector().text("{webvIEw}")'                                                        '.instance(0));').click()        print(self.driver.contexts)        self.driver.switch_to.context(self.driver.contexts[1])        print(self.driver.current_context)        self.driver.find_element(MobileBy.ID, 'i am a link').click()
--THE END--

文章标题:AndroID WebVIEw测试
本文作者:hiyo
本文链接:https://www.cnblogs.com/hiyong/p/14163722.html
欢迎关注公众号:「测试开发小记」及时接收最新技术文章!

总结

以上是内存溢出为你收集整理的Android WebView测试全部内容,希望文章能够帮你解决Android WebView测试所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/web/1049448.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存