RFS自动化测试工具安装与使用总结

Posted 程序员二黑.

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RFS自动化测试工具安装与使用总结相关的知识,希望对你有一定的参考价值。

一,调试

1,在调试时,总时提示“无法打开浏览器”
解决办法:
1,把浏览器的代理关闭
2,把浏览器的显示比例调到100%
3,在IE设置的安全选项中,把启用保护模式开启
4,去除进入系统弹出的登录提示
在浏览器中—工具—internet选项—安全—把只在intranet自动登录,改为匿名登录

二,安装加载库

1,RequestsLibrary
先安装Requests工具,再安装RequestsLibrary
再在robot中进行加载lib,如果加载的库还是红色的,重启就可以了

三,常用关键字

open browser 打开浏览器
input text 在文本框中录入内容
input password 在文本框中录入密码
click button 点击按钮
page should (NOT)contain (link,button,element,checkbox,list) 页面是否出现指定的内容

close browser 关闭浏览器

多个打开浏览器切换
open browser http://127.0.0.1:8000/ ie local
switch browser local

针对页面弹出窗口的确认键
confirm action----类似于点击弹出窗的确认或OK键

alert should be present 当前弹窗的内容 -----判断当前指定内容的弹窗是否存在

get alert message—获取弹出窗的信息

$msg= get alert message

should be equal as string $msg *****

在弹窗中选择取消操作

a,choose cancle on next confirmaction

b,confirm action

设置日志级别
Set Log Level TRACE

下拉列表
select from list xpath value
select from list by value xpath value
select from list by index xpath value

框架
select frame id=fra
unselect frame

复选框
select checkbox id=CheckYes
unselect checkbox id=CheckNo

checkbox should not be selected
select checkbox
checkbox should be selected

单选框
select radio button radio1—单选框名称 A–value)

click element id=registerGenderMale

Oracle数据库
connect to database using custom params(关键字) cx_Oracle 用户名,密码,SID
$row row count select * from 表1;

等待页面加载
wait until page contains element
sleep
reload page—刷新

注释
Comment

几个关键字的区别
Wait Until Keyword Succeeds
wait until page contains element
SLEEP
element should contain
page should contain element
page should contain
Element Should Not Be Visible

判断的使用

判断条件—数字对比
Run Keyword If $res == 0 执行的关键字
… ELSE 执行的关键字2

判断条件—字符对比
Run Keyword If ‘ r e s ’ = = ‘ t t t t t ′ 执行的关键字判断条件 − − − 布尔类型对比 R u n K e y w o r d I f ′ res’ == ‘ttttt' 执行的关键字 判断条件---布尔类型对比 Run Keyword If ' res==ttttt执行的关键字判断条件布尔类型对比RunKeywordIfres’ == ‘$true’ 执行的关键字

HTTP接口
create session httpserver http://localhost:8000
$addr Get request httpserver users/s
should be equal as strings $addr.status_code 200
log $addr.content
$resp tojson $addr.content

四,常见问题解答

1,定位不到元素
Element locator ‘//input[@id=“registerName”]’ did not match any elements.
前端代码

解决方法: 先从最里面的元素开始一级一级往上找,找到iframe,然后先select frame这个ID就可以定位到里面的元素了。

2,InvalidElementStateException: Message: u’Element must not be hidden, disabled or read-only’
针对根据复选框的状态,解决文本框中默认带出内容时。如果这样写就会报错
select checkbox id=noLicenseFlag
input text id=registerName 湘A*
像这样的组合,后面那句input text id=registerName 湘A*直接删除就可以了。

3,页面操作按钮提示找不到elements
click button id=carInfoSubmitBtn
改为click element id=carInfoSubmitBtn

4,根据录入框内容弹出框框,定位不到元素
采用相对路径的方式定位,用firefox浏览器打开地址,按F12获取元素位置,右击—选择复制XPATH
放在脚本中形式为:xpath=/html/body/div[9]/div[2]/table/tbody/tr[4]/td[4]

6,InvalidElementStateException: Message: u’Element must not be hidden, disabled or read-only’
出现这个现象是因为脚本执行快,而页面的元素还没有加载完成造成的。
等待页面加载
wait until page contains element或sleep

7,页面执行时没有报错,但一直停在那里了
利用Mouse out 关键字,移开鼠标动作。

8,使用close broswer关闭浏览器不起作用
首先安装pywin32-217.win32-py2.7.exe,再安装AutoItLibrary库,在close broswer关键字
下一行,增加删除进线的关键字: process close iexplore.exe

10,查看所有有关robot相关库的版本
pip list

11,通过pip升级库或程序版本
1,Python -m pip install --upgrade pip
报错:
You should consider upgrading via the ‘python -m pip install --upgrade pip’ command.
2,根据提示,执行命令
python -m pip install --upgrade pip
报错:Requirement already up-to-date: pip in c:\\python27\\lib\\site-packages
3,找到c:\\python27\\lib\\site-packages下这个目录pip-8.1.1.dist-info并删除,重新执行
python -m pip install --upgrade pip
4,查看是否更新成功
pip list后显示最新版本

12,利用pip更新库或RIDE或robot
pip install robotframework-ride --upgrade
再用pip list可以看到升级成功的版本号了

13,Run Keyword And return status关键字识别不了
利用pip更新RIDE,robot,selenium2Library

14,ImportError:No module named cx_Oracle
根据连接oracle客户端的版本如:11G,操作系统是32位还是64位
安装对应的cx_Oracle安装包,如:cx_Oracle-5.1.2-11g.win32-py2.7

15,Unable to acquire Oracle environment handle
在oracle客户端的目录中把oci.dll,oraocci11.dll,oraociei11.dll文件复制到C:\\Python27\\Lib\\site-packages目录中

16,日志目录
Log: d:\\users\\liujun~1\\appdata\\local\\temp\\RIDEwzyfth.d\\log.html
Report: d:\\users\\liujun~1\\appdata\\local\\temp\\RIDEwzyfth.d\\report.html

17,在IE中如果click不起作用,用如下关键字
press key id=kw \\13

18,单选框实例

select radio button register.gender M

19,下拉列表实例

select from list class="pa_ui_dropselect_inner paui-clearfix" 江北区

20,通过PIP安装Selenium2Library报错
C:\\Users\\Administrator>pip install Selenium2Library
Collecting Selenium2Library
Could not find a version that satisfies the requir
versions: )
No matching distribution found for Selenium2Library

解决办法:
pip install robotframework-Selenium2Library
就可以了

21,安装IEDriver报错
WebDriverException: Message: ‘IEDriverServer.exe’ executable needs to be in PATH. Please download fromhttp://selenium-release.storage.googleapis.com/index.html and read up athttps://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
解决办法:
下载对应系统版本的IEDriverServer.exe放在IE的安装目录下和Python的根目录下,并设置PATH。

22,滚动鼠标拖动滚动条到最顶部或最底部
execute javascript id.scrollTop其中id为滚动条区域对应的id,用法:
如:execute javascript J_introCon.scrollTop=0是拖到最顶部,execute javascript J_introCon.scrollTop=100000是拖到最底部

23,在CASE中的setup中可以设置运行CASE前,运行SETUP里面的关键字。teardown中可以设置运行CASE后,指定要运行的关键字

24,满足条件结束脚本
exit for loop
如:如果count值为0,则结束CASE
run keyword if $count==0 exit for loop

25,执行SQL时报错:DatabaseError:ORA-00911:Invalid character
去掉SQL后面的 ;

26,执行SQL查询
Execute sql String select * from 表名

最后:下方这份完整的软件测试视频学习教程已经整理上传完成,朋友们如果需要可以自行免费领取 【保证100%免费】

以上是关于RFS自动化测试工具安装与使用总结的主要内容,如果未能解决你的问题,请参考以下文章

python+uiautomator2+fiddler 自动化测试项目总结

Robot Framework使用Phantomjs进行无界面UI自动化测试

——测试自动化及其框架 重点部分总结

——测试自动化及其框架 重点部分总结

——测试自动化及其框架 重点部分总结

自动化测试学习总结:ie,chrome,firefox各个driver安装和使用之Firefox