当前位置:网站首页>How does app automated testing achieve H5 testing
How does app automated testing achieve H5 testing
2022-07-28 19:35:00 【Zeze said test】
Mobile app There are many automation frameworks , However, some frameworks do not support mixed application testing , It hasn't been completely popular . The more typical is the classic Python frame uiautomator2, This framework is simple and easy to use , No, appium So complicated api call , A lot of python Favor of Automation Engineers .
But whether it's official documents , Or folk tutorials , Basically, it doesn't involve mixed application testing with it , This article provides a very simple method , Just add 4 Line code , You can make uiautomator2 Support mixed application testing .
What is hybrid application
There are two typical development methods for mobile applications , One is original native app, One is based on web development technology web app. The experience of native applications is better , But if you want to develop Android applications and ios application , Need different native development technologies . web Applications can easily do Android and ios Cross platform development of , It's a little less experiential , Not as smooth as native applications .
Hybrid App( Hybrid mobile applications ) Is between web app and native app Development methods between , You can nest web pages in the native interface , Therefore, it can have a sense of experience and cross platform ability at the same time .
At present, the mainstream mobile terminal app The test framework appium Have the ability of mixed application testing , However, it is troublesome to build and use this framework , The method of encapsulation is not so pythonic, So many companies don't want to use , They prefer simple and elegant python uiautomator2 frame . Very regret , This framework does not support mixed application testing at present .
WebView Automated test steps
- First step , Enter... Through native operation webview Webpage ;
- The second step , Use selenium Wait for the web test tool to enter the web page ;
- The third step , Use selenium And other web testing tools .
The key step is how to use selenium, If you open a new one directly selenium conversation , Then a new page will open , and app Medium webview It's separate. , Therefore, nested pages cannot be detected . selenium And app Build a relationship , Bind them together , operation selenium Direct operation is when app The web page in .
adopt uiautomator2 Get into webview
Here is the most basic uiautomator2 operation , Detailed operations can be viewed Official documents , the app yes android bootstrap, Can directly Click to download .
d = u2.connect()
d.app_start('com.github.android_app_bootstrap')
d(text='Login').click()
d(text='Baidu').click()
selenium Connect webview
APP The third menu can be opened directly baidu Webpage , So as to webview Webpage . If not used selenium Connect , Directly through uiautomator2 Locate the elements in the web page , It's a mistake .
How to get through selenium Connect webview Well ?
- First , Through the equipment d Gets the of the current operation app, To get the package name
- then , Initialize a Chrome Browser object
- It should be noted that ,Chrome Object needs to add additional parameters , Specify the connected device ,webview Bound enrollment , And configuration in app Use in android browser .

The subsequent operation is the same as selenium do web Automated testing makes no difference , Nothing more than clicking on the web , Do automated operations :
driver = webdriver.Chrome('chromedriver_68.exe', options=options)
driver.implicitly_wait(8)
driver.find_element('id', 'index-kw').send_keys(' Hello ')
WebView Description of automated test in browser
Are you curious , How do I know to write code like this , To connect webview , Achieve the test effect ? In fact, there are not so many mysterious learning methods in the world , As long as you are willing to work hard , There must be a way to learn . This code is clearly written in chrome webdriver In the official documents of , It's just , You may not be able to open it . Take a screenshot :

other webdriver You can also view the configuration of MDN web docs.
Show the effect :
I'm nine , official account 【 Nine handles 】, Share software testing articles 、 interview 、 Tutorial materials , Welcome to see .
边栏推荐
- 助力面板行业创新,FPGA将成屏厂TCON最佳选择?
- ardupilot软件在环仿真与在线调试
- Rust 入门指南(crate 管理)
- China's first chip stamp released: built-in 120um ultra-thin NFC chip
- source insight项目导入和使用教程
- Swing事件处理的过程是怎样的?
- 英文翻译意大利语-批量英文翻译意大利语工具免费
- English article translation - English article translation software - free batch translation
- VAE:变分自编码器的理解与实现
- Mid 2022 summary
猜你喜欢
随机推荐
Share several coding code receiving verification code platforms, which will be updated in February 2022
Cell综述:人类微生物组研究中的单细胞方法
IMU 加热
BLDC 6-step commutation simulink
Saltstack configuration management
Dockler的基础用法
Huawei shares in Nanjing core vision, laying out the solid-state laser radar chip field
英文翻译葡萄牙语-批量英文转换葡萄牙语-各种语言免费互译转换
After reading the thesis for three years, I learned to read the abstract today
Transformer for anomaly detection - instra "painting transformer for anomaly detection"
SaltStack系统初始化
App自动化测试是怎么实现H5测试的
Taking the opportunity of digital transformation, how can 3C enterprises achieve efficient collaboration through SRM supplier cloud collaboration platform?
用于异常检测的Transformer - InTra《Inpainting Transformer for Anomaly Detection》
Test Development Notes
可转债概念表 x Notion 给你方便快捷的体验!
微信公众号授权登录后报redirect_uri参数错误的问题
Nokia expands its 5g agreement with BT and will become its largest wireless access device supplier
shared_ptr 和 make_shared 的使用
Sword finger offer II 109. unlock the password lock









