robotframework关键字常用
程序员文章站
2024-03-23 21:40:46
...
*** Settings ***
Library Selenium2Library
Library Collections
*** Test Cases ***
allkeyword
open browser url gc/ff/ie jd #打开浏览器页面,页面取别名jd
select frame id=e_frame #进入frame
unselect frame #退出frame
input text locator text #先输入位置,再输入内容
input password lactor password #同input text
click element lacator #元素鼻祖
click link text #直接填链接标签text
click button lacator #点击提交按钮
sleep second #强制等待单位秒
${result}= get webelements locators #获取一类元素,定位选取类或xpath
set \ browser implicit wait second #设置隐等待,单位秒,凹凸曼来了就走
comment #注释掉不运行此关键字,快捷f3,取消f4
wait until element is visible lacator #等待元素可见
Wait Until Page Contains text #等待页面包含文本
Wait Until Page Contains Element locator #等页面元素到出现
${result} get \ text locator #获取元素标签文本
${result} get element count locator #获取元素数量,div标签一类元素计数
should be equal ${result} expect #first为实际结果,second预期断言鼻祖
should contain ${result} text #预期需要包含,断言
select window new #跳转到latest window
Select From List By Index locator 1 #一般name=lsdd,然后索引0起
Select From List By label locator text #locator 为select,name一般,,文本查询
Select From List By Value lacator 1001 #value值
Select All From List locator #select的name=lsdd全选标签
select checkbox locator #单选checkbox
${result}= get webelement //*[@class='tb tb2 ']/tbody/tr[11]/td/ul/li[1]/input #第一步,获取所有checkbox元素,appendlist
:FOR ${i} IN ${result} #迭代
\ log ${i} #调试打印结果
\ click \ element ${i} #其实也可以写list为@{list} 整个为全选checkbox;100个你不累趴下
select radio button groupname 2 #group名为设么,value值多少
${result}= Get Element Attribute lacator checked #获取check属性的值,断言为true,none
log many #打印 多元素标量 #log dictionary
choose file locator d:\\xiaochen.txt #文件上传
page should contain text #断言,页面需要
table should \ contain //*[@id='cpcontainer']/form/table text #表断言,表文本
${result} get table cell lacator#表xpath row cloumn
should contain ${result} text #表细胞层断言
Table Column Should Contain locator cloumn text #表列包括断言
assign id to element locator ls_id #id添加只传id值,方便定位
mouse over lactor #悬停
Go To url #进入url
maximize browser \ window #最大化
press key lactor \\13
go \ back #页面后退
Dismiss Alert true #弹窗处理,单出确认的 true表示确定,false表示取消
Wait Until Keyword Succeeds 10 2 input text id=ddd text
${values} Get Dictionary Values ${dict}
${result} Get Alert Message
Choose Ok On Next Confirmation #弹窗确认
confirm action #这个确认步骤
Choose Cancel On Next Confirmation
confirm \ action #取消按钮
${result} evaluate python #转换脚本关键字,强大的一笔
Unselect All From List selectname #全不选下拉框
Unselect Checkbox lacator #全不选复选框
上一篇: const在编译期的替换问题