Part-Selenium-1

1.在浏览器中的console输入:帮助定位css

> $x('xpath表达式')html

> $('css表达式')java

2.driverpython

> chrome driver: https://npm.taobao.org/mirrors/chromedriverandroid

> firefox:https://github.com/mozilla/geckdriver/realeases/tag/v0.24.0ios

3.简易的页面性能git

> raw_json = webdriver.execute_script("return JSON.stringify(window.performance.timing)"),返回的内容,比requests多,有些事它拿不到的github

4.remote serverweb

> 下载selenium server,启动算法

> 经过webdriver.remote()来链接到服务器

5.UI自动化测试策略

> 核心业务自动化

> 接口测试是否能够保证,能够,ui测试能够适当弱化

> 涉及用户交互的重要功能,仍然能须要使用UI自动化测试保证

6.测试痛点

> 快速迭代中自动化用例吃力

    没有采用po模式,致使自动化用例维护成本大

    对自动化框架掌握程度不够

> 测试内容太多致使手工测试没法充分覆盖

    界面字段正确性

    接口正确性:后端接口传输数据的变化和内容

    专项测试回归难度大:内存泄漏,健壮性测试,弱网等  测试过程太多

    回归工做量大,不回归又会漏测

改进:

>  自动化:覆盖主要业务的right path,缩小规模尽可能下降维护成本

>  手工:覆盖新功能测试,探索性测试

> 遍历测试手段:code less:用例维护成本降到最低

                            automate:尽量的自动化覆盖回归业务

自动遍历需求:可控,可定制

结果分析:点击先后截图对比,结果的数据建模,新老版本的diff,app结构思惟导图展现

monkey:https://developer.android.com/studio/test/monkey

adb shell monkey -p com.ebo.home/com.ebo.home.Launcher --throttle 1000 --pct-touch 50 -v 500 

> throttel,每一个时间的间隔时间

> pct-touch,touch时间的占比

> -v  500,500次事件

> -s  指定种子值

monkeyrunner,功能较弱,使用python代码中调用java,不建议使用

Maxim:

高速uiautomator控件解析算法的Android Monkey, 每秒10-15个Action Event。实现快速DFS算法的Android Monkey , 每秒 5个Action Event。

git clone https://github.com/zhangzhao4444/Maxim.git
cd Maxim
adb push framework.jar /sdcard
adb push monkey.jar /sdcard
adb shell CLASSPATH=/sdcard/monkey.jar:/sdcard/framework.jar exec app_process /system/bin tv.p.test.monkey.Monkey -p com.xueqiu.android --uiautomatormix --running-minutes 5 -v -v

AppCrawler:

Usage: appcrawler [options]

-a, --app <value> Android或者iOS的文件地址, 能够是网络地址, 赋值给appiumapp选项
-e, --encoding <value> set encoding, such as UTF-8 GBK
-c, --conf <value> 配置文件地址
-p, --platform <value> 平台类型android或者ios, 默认会根据app后缀名自动判断
-t, --maxTime <value> 最大运行时间. 单位为秒. 超过此值会退出. 默认最长运行3个小时
-u, --appium <value> appiumurl地址
-o, --output <value> 遍历结果的保存目录. 里面会存放遍历生成的截图, 思惟导图和日志
--capability k1=v1,k2=v2...
appium capability选项, 这个参数会覆盖-c指定的配置模板参数, 用于在模板配置之上的参数微调
-r, --report <value> 输出htmlxml报告
--template <value> 输出代码模板
--master <value> masterdiff.yml文件地址
--candidate <value> candidate环境的diff.yml文件
--diff 执行diff对比
-vv, --verbose 是否展现更多debug信息
--demo 生成demo配置文件学习使用方法
--help
示例
appcrawler -a xueqiu.apk
appcrawler -a xueqiu.apk --capability noReset=true
appcrawler -c conf/xueqiu.json -p android -o result/
appcrawler -c xueqiu.json --capability udid=[你的udid] -a Snowball.app
appcrawler -c xueqiu.json -a Snowball.app -u 4730
appcrawler -c xueqiu.json -a Snowball.app -u http://127.0.0.1:4730/wd/hub

#生成demo例子
appcrawler --demo

#启动已经安装过的app
appcrawler --capability "appPackage=com.xueqiu.android,appActivity=.view.WelcomeActivityAlias"

#从已经结束的结果中从新生成报告
appcrawler --report result/

#新老版本对比
appcrawler --candidate result/ --master pre/ --report ./
java -jar appcrawler-2.4.0-jar-with-dependencies.jar --capability "appPackage=com.xueqiu.android,appActivity=.view.WelcomeActivityAlias"
java -jar appcrawler-2.4.0-jar-with-dependencies.jar --demo
#把生成的demo.yaml文件重命名demo_1.yaml
java -jar appcrawler-2.4.0-jar-with-dependencies.jar -c demo_1.yml1.执行参数与配置文件> capability设置:与appium彻底一致> testcase:用于启动app后执行基础测试用例> selectedList:遍历范围设定> triggerActions:特定条件触发执行动做的设置执行参数比配置文件优先级别高2.capability:appPackage:""appActivity:""app:""appium:"http://127.0.0.1:4723/wd/hub"noReset:trueautomationName:uiautomator2dontStopAppOnReset:true3.自动化支持testcase>testcase的完整形态:i.given:全部的先决条天,when:先决条件成立后的行为,then:断言集合autoCrawl:truetestcase: name:demo1 steps: - when: xpath://.... action:driver.swipe(1,2,3,4) - when: xpath://... action:driver.... - xpath:登陆 action:click then: - //*[contains(@text, "密码")]testcase的简写形态: xpath:对应when里的xpath action:对应when里的action定位模式:xpath,正则,包含action:back后退backApp回退到当前的app,默认等价与back行为monkey随机事件xxx()执行代码Thread.sleep(3000)driver.swipe(1,2,3,4)clicklongTap非以上全部行为是输入 xx ddd4.自动遍历SelectedList:指定遍历范围,看demo.yaml中包含,button,文本(其clickable=true),图片等firstList:优先遍历lastList:最后遍历backButton:当素有元素都被点击后默认后退按钮triggerAction:特定事件xpathAttributes:xpath默认有哪些属性,通常要去掉instanceblackList:黑名单maxDepth:最大遍历深度5.参数-c 指定配置文件-o /tmp/1 指定输出结果路径
本站公众号
   欢迎关注本站公众号,获取更多信息