当前位置:网站首页>Automated testing of Android wechat applet for automated testing of dry goods | app
Automated testing of Android wechat applet for automated testing of dry goods | app
2022-04-21 18:28:00 【Hua Weiyun】
With the function and ecology of wechat app becoming more and more perfect , Many companies have more and more page structures for small program projects , Business logic is becoming more and more complex . How to do a good job in the automatic testing of small programs has become a major pain problem faced by testing students .
Wechat applet
The applet is embedded in wechat , The page contains Native Primitives and Web Elements , Equivalent to hybrid applications . also , Applet Web Partly based on Tencent's X5 Kernel developed , It's also special WebView. that , Automatic testing of wechat applet , Including operating native applications 、WebView、 Based on wechat Official Automation SDK.
WebView Page element acquisition
Use the element positioning tool :
- weditor
weditor Installation mode
pip install weditor
Reference documents :https://github.com/alibaba/web-editor
Use chrome inspect When positioning , Parsing element is to parse the page into html page , Use weditor, Then the page will be parsed into a native page , and Appium When manipulating elements , It also parses the page into a native to operate ( Switch webview With the exception of )

Mac:
adb shell dumpsys activity top| grep ACTIVITY
Windows:
adb shell dumpsys activity top| findstr ACTIVITY


from time import sleepfrom appium import webdriverclass TestDemo: def setup(self): self.desire_cap= { 'automationName': "uiautomator2", "platformName": "Android", "deviceName": "wechat", "appPackage": "com.tencent.mm", "appActivity": ".ui.LauncherUI", "noReset": "true", 'chromeOptions': {'androidProcess': 'com.tencent.mm:appbrand0'} } # androidProcess:webview It's an independent process , It makes it impossible to get , Need to be in chromeOptions add to androidProcess that will do self.driver=webdriver.Remote("http://127.0.0.1:4723/wd/hub",self.desire_cap) self.driver.implicitly_wait(20) def teardown(self): self.driver.quit() def test_demo(self): # When I first opened wechat , Unknown page load time , # Need to pass through find_element Trigger implicit wait , Prevent subsequent operations from failing self.driver.find_element_by_xpath("//*[@text=' Mail list ']") size = self.driver.get_window_size() # Gets the width of the current screen 、 high width = size.get("width") height = size.get("height") # Slide to open the applet page self.driver.swipe((width / 2), int((height * 0.2)), (width / 2), (height * 0.8), 2000) self.driver.find_element_by_xpath("//*[@resource-id='com.tencent.mm:id/gam' and @text=' Snowball ']").click() sleep(5) print(self.driver.contexts,' First printing ') self.driver.find_element_by_xpath("//*[@content-desc=' Search for stock information / Code ']/..").click() self.driver.find_element_by_xpath('//*[@text=" Please enter the stock name / Code "]').send_keys(" Alibaba ") text = self.driver.find_element_by_xpath('//*[@content-desc=" Alibaba "]') assert text
- Simulator :Genymotion
- System version :8.1
- Wechat version :7.0.15
- Applet : Snowball
- http://appium.io/docs/en/writing-running-appium/caps/
- https://sites.google.com/a/chromium.org/chromedriver/capabilities
- https://sites.google.com/a/chromium.org/chromedriver/getting-started/getting-started---android
There are many ways to test small programs , Because the wechat version is often upgraded ,webview Your settings will also change , Therefore, the available test methods may vary from version to version . For more available testing methods, please refer to the tester Forum :https://ceshiren.com/t/topic/12403
Link to the original text
Get more :https://qrcode.ceba.ceshiren.com/link?name=article&project_id=qrcode&from=hwyun×tamp=1650524546
版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211823418984.html
边栏推荐
- Target penetration exercise 76-dc8
- No more simple intention lock
- MySQL - remote connection to non local MySQL database server, Error 1130: host 192.168.3.100 is not allowed to connect to this MySQL s
- Huawei, TCL, Dajiang
- Advanced formula 45 of C language: the secret of function parameters (Part 2)
- Huawei level 18 Daniel collates and summarizes: microservice design and distributed service framework principle practice document
- 刚拿的字节跳动offer“打水漂”
- 靶机渗透练习77-DC9
- 曾经被爆买的产品又来了,求稳买他准没错
- MySQL安装的初始密码在哪看?
猜你喜欢

php如何去除首位数字

win10 uwp 异步进度条

Which immortal wrote 421 pages of advanced notes on MySQL, covering all MySQL technologies! It's so sweet

Huawei, TCL, Dajiang

Target penetration exercise 73-dc5

靶机渗透练习80-Momentum:1

How does IOT platform realize business configuration center

靶机渗透练习73-DC5

观测云登陆阿里云计算巢,共建ISV新生态

No more simple intention lock
随机推荐
Laravel soar (2. X) - automatically monitor and output SQL optimization suggestions and assist laravel to apply SQL optimization
ACM纪念日 C语言
2021-5-2 第二天第二题
Tooltip component: judge whether to display tooltip according to whether the content overflows
How to test Android WebView for automated testing of dry goods app
统计组成的四位数 C语言
Teach you to easily solve CSRF Cross Site Request Forgery Attack
[pytorch image classification] RESNET network structure
Hero King C language
The difference between integer, equals and = =
Composant tooltip: déterminer si tooltip est affiché en fonction du débordement de contenu
图文并茂 教你在IDEA中如何一键生成代码,提高开发效率!
win10 uwp 异步进度条
再见SharedPreferences,你好MMKV!
【小程序】支付宝小程序自定义下拉刷新组件
Detailed explanation of kubernetes (III) -- kubernetes cluster components
Redis-benchmark性能测试工具使用详解
[牛客网刷题 Day4] JZ23 链表中环的入口结点
WPF学习笔记——概述
靶机渗透练习74-DC6