RF-APP自动化测试-「Android」

RF-APP自动化测试-「Android」

RF框架+Appium也是可以编写app自动化case的,用appium作为一个服务,只要给RF脚本一个 http://localhost:4723/wd/hub的服务地址;远程的话,把localhost 换成具体的ip或域名;

RF-APP自动化测试-「Android」

测试Android上的应用,大概需要以下环境:

1.java jdk

2.android的sdk

3.python

4.appium

5.nodejs

6.Appium-python-Client

7.AppiumLibrary

因为目前暂不做app的测试了,没有具体的环境,就不给大家演示环境的搭建了,还望见谅,网上有很多相关的基础环境搭建教程,大神们写的都挺好的,大家可以去自行搜索哈。

本次主要是给大家分享的是基于RF框架下case的编写;因为Android的模拟器非常的慢,所以下面的"启动配置"是以真机为基准来启动的;

var.py 里面是变量的参数,就不放出来了


脚本封装.txt


RF-APP自动化测试-「Android」

*** Settings ***
Variables var.py
Library AppiumLibrary
 
*** Keywords ***
accept_alert
 : FOR ${i} IN RANGE 2
 \ Wait Until Page Contains Element xpath=//android.widget.Button[2] ${timeout}
 \ Click Element xpath=//android.widget.Button[2]
 \ log ${i}

具体的case如下:


*** Settings ***
Library AppiumLibrary
Variables var.py
Resource 脚本封装.txt
 
*** Test Cases ***
启动配置
 Comment android和APPIUM的配置信息
 Open Application http://localhost:4723/wd/hub platformName=${platformName} platformVersion={platformVersion} deviceName=${deviceName} app=${app} appPackage=${appPackage}
 Comment 等待启动页的按钮出现,设置最多等待${timeout}s
 Wait Until Page Contains Element xpath=//android.widget.Button ${timeout} ${timeout}s内未定位到元素
 Comment 点击启动页的按钮
 Click Element xpath=//android.widget.Button
 
登录
 Wait Until Page Contains Element xpath=//android.widget.LinearLayout[1]/android.widget.EditText ${timeout} ${timeout}s内未定位到元素
 Run Keyword And Ignore Error accept_alert
 Comment 输入用户名
 Input Text xpath=//android.widget.LinearLayout[1]/android.widget.EditText ${username}
 Comment 输入密码
 Input Password xpath=//android.widget.LinearLayout[2]/android.widget.EditText ${password}
 Comment 点击登录按钮
 Click Element xpath=//android.widget.Button
 
抽屉页
 Comment 等待抽屉按钮出现,设置最多等待${timeout}s
 Wait Until Page Contains Element xpath=//android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.LinearLayout ${timeout} ${timeout}s内未定位到元素
 Comment 点击抽屉按钮
 Click Element xpath=//android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.LinearLayout
 
抽屉_应用_报销
 Comment 定位到应用并点击
 Click Element xpath=//android.widget.RelativeLayout[3]
 Comment 定位到报销并点击
 Sleep 2
 Click Element xpath=//android.widget.ExpandableListView/android.widget.RelativeLayout[7]
 Wait Until Page Contains Element xpath=//android.widget.LinearLayout[2]/android.widget.TextView[2] ${timeout} ${timeout}s内未定位到元素
 Comment 定位到新建并点击
 Click Element xpath=//android.widget.LinearLayout[2]/android.widget.TextView[2]
 Comment 定位到项目并点击
 Click Element xpath=//android.widget.ScrollView/android.widget.LinearLayout/android.widget.RelativeLayout[1]
 Comment 选择直接报销
 Wait Until Page Contains Element xpath=//android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.LinearLayout ${timeout} ${timeout}s内未定位到元素
 Click Element xpath=//android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.LinearLayout
 Comment 定位到开始时间并点击
 Click Element xpath=//android.widget.ScrollView/android.widget.LinearLayout/android.widget.RelativeLayout[2]
 Comment 点击确定
 Click Element xpath=//android.widget.RelativeLayout/android.widget.Button[2]
 Comment 定位到结束时间并点击
 Click Element xpath=//android.widget.ScrollView/android.widget.LinearLayout/android.widget.RelativeLayout[3]
 Click Element xpath=//android.widget.RelativeLayout/android.widget.Button[2]
 Comment 保存下一步
 Click Element xpath=//android.widget.RelativeLayout/android.widget.Button
 
添加报销明细
 Wait Until Page Contains Element xpath=//android.widget.RelativeLayout[2]/android.widget.ImageView ${timeout} ${timeout}s内未定位到元素
 Comment 进入报销明细
 Click Element xpath=//android.widget.RelativeLayout[2]/android.widget.ImageView
 Wait Until Page Contains Element xpath=//android.widget.ScrollView/android.widget.LinearLayout/android.widget.RelativeLayout[1] ${timeout} ${timeout}s内未定位到元素
 Comment 定位到报销分类并点击
 Click Element xpath=//android.widget.ScrollView/android.widget.LinearLayout/android.widget.RelativeLayout[1]
 Comment 选择默认第一个报销分类
 Click Element xpath=//android.widget.RelativeLayout/android.widget.Button[2]
 Comment 定位到金额并点击
 Click Element xpath=//android.widget.ScrollView/android.widget.LinearLayout/android.widget.RelativeLayout[2]
 Wait Until Page Contains Element xpath=//android.widget.LinearLayout[2]/android.widget.Button[2] ${timeout}
 Comment 点击数字“8”
 Click Element xpath=//android.widget.LinearLayout[2]/android.widget.Button[2]
 Comment 点击“+”
 Click Element xpath=//android.widget.LinearLayout[3]/android.widget.ImageButton[1]
 Comment 点击数字“1”
 Click Element xpath=//android.widget.LinearLayout[4]/android.widget.Button[1]
 Comment 点击数字“0”
 Click Element xpath=//android.widget.LinearLayout[5]/android.widget.Button[1]
 Comment 确定金额
 Click Element xpath=//android.widget.LinearLayout[5]/android.widget.Button[4]
 Comment 定位到'张数'并输入内容
 Input Text xpath=//android.widget.RelativeLayout[3]/android.widget.EditText 8
 Run Keyword And Ignore Error Hide Keyboard
 Comment Register Keyword To Run On Failure Hide Keyboard
 Comment ${msg} Run Keyword And Expect Error None Wait Until Page Contains Element xpath=//android.widget.LinearLayout/android.widget.Button[2] 2
 Comment ${return} Run Keyword And Return Status Wait Until Page Contains Element xpath=//android.widget.LinearLayout/android.widget.Button[2] 2
 Comment Run Keyword If ${return}==False Go Back
 Comment Press Keycode 4
 Comment 点击上传图片按钮
 Click Element xpath=//android.widget.GridView/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.ImageView
 Comment 选择相册
 Click Element xpath=//android.widget.LinearLayout/android.widget.TextView[3]
 Comment 选择一个图片
 Click Element xpath=//android.widget.ListView/android.widget.RelativeLayout[1]
 Wait Until Page Contains Element xpath=//android.widget.LinearLayout/android.widget.Button[2] ${timeout}
 Comment 点击 添加完成 按钮
 Click Element xpath=//android.widget.LinearLayout/android.widget.Button[2]
 Wait Until Page Contains Element xpath=//android.widget.Button ${timeout} ${timeout}s内未定位到元素
 Comment 点击弹窗的确定按钮
 Click Element xpath=//android.widget.Button
 Wait Until Page Contains Element xpath=//android.widget.LinearLayout[2]/android.widget.Button[2] ${timeout} ${timeout}s内未定位到元素
 Comment 点击提交按钮
 Click Element xpath=//android.widget.LinearLayout[2]/android.widget.Button[2]
 Wait Until Page Contains Element xpath=//android.widget.Button ${timeout} ${timeout}s内未定位到元素
 Click Element xpath=//android.widget.Button
 
卸载app
 Remove Application ${appPackage}
 
kill 进程
 Comment 杀掉该app在appium服务中的进程
 Close Application
 

【如果认可,还望转发;您的支持,是我继续的动力!】

【如有建议,还望赐教;您的鞭策,是我努力的方向!】

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
RF接口自动化测试是指使用Robot Framework(简称RF)进行的接口自动化测试。在进行RF接口自动化测试时,需要掌握一些基础知识和技巧。 首先,要了解RF的基本概念和用法。RF是一种开源的,基于关键字驱动的测试框架,支持Python语言编写测试用例。它提供了丰富的库和关键字,方便编写、维护和扩展测试脚本。 在RF接口自动化测试中,需要使用HTTP库或者比较流行的第三方库如Requests库来发送HTTP请求,并解析返回的结果。可以通过编写关键字来封装这些操作,方便进行测试用例的编写和维护。 其次,要了解接口测试的基本原理和流程。对于每个接口,需要先明确测试目标和约束条件,然后设计测试用例,包括输入数据和预期结果。通过RF提供的关键字,可以执行测试用例,并比较实际结果和预期结果,判断接口是否正确。 在RF接口自动化测试中,还需要考虑一些常见的问题和注意事项。例如,如何处理接口依赖关系和参数化测试、如何处理错误和异常情况、如何生成测试报告和日志等。可以借助RF提供的库和关键字,来解决这些问题,并提高测试效率和质量。 最后,要了解RF接口自动化测试的发展趋势和扩展领域。随着互联网的发展,接口测试变得越来越重要。对于RF接口自动化测试,可以考虑与其他测试技术和工具的集成,如数据库测试、性能测试、安全测试等,以提供更全面的测试覆盖和更高的测试效率。 总之,RF接口自动化测试是一种灵活、高效的测试方法,可以帮助我们快速、准确地发现接口中的问题。掌握RF接口自动化测试需要掌握RF框架的基本概念和用法,了解接口测试的原理和流程,并学会解决常见问题和扩展领域。通过不断学习和实践,我们可以提高自己的RF接口自动化测试水平,为软件质量的提升做出贡献。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

测试界

您的支持是我前进的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值