1.rf常用关键字和快捷键的使用
1.1快捷键
搜索关键字 F5
自动补全关键字 Ctrl+shift+空格
1.1 打印
Log
1.2 设置变量
Set Variable
1.3 注释
Comment
1.4 列表
1.4.1 列表创建
Create List
1.4.2 列表输出
Log
Log Many
1.5 字典
1.5.1 字典创建
Create Dictionary
1.5.2 获取字典的key
Get Dictionary Keys
1.5.3 获取字典的value
Get Dictionary Values
1.5.4 获取字典的item
Get Dictionary Items
1.5.6 根据key获取value
Get From Dictionary
1.6 字符串
1.6.1 字符串拼接
Catenate
1.7 时间处理
1.7.1 获得系统时间
Get Time
1.8 if语句
if嵌套时需要使用自定义关键字
Run Keyword If ${age}>30 Log 年龄太大
... ELSE IF 18<=${age}<=30 嵌套if
... ELSE Log 未成年
1.9 循环
1.9.1 for循环
FOR ${a} IN apple orange banlana
Log ${a}
END
1.9.2 for in_range循环
FOR ${a} IN RANGE 1 20
Run Keyword If ${a}==5 Exit For Loop
Log ${a}
END
1.10 方法的使用
1.10.1 内置方法
${random_number} Evaluate random.randint(1,101) modules=random
1.10.2 自定义方法
Import Library D:/python_record/tool.py
${a} Evaluate int(10)
${b} Evaluate int(20)
${result} add ${a} ${b}
2.元素定位
2.1 id
id=kw
2.2 name
name=wd
2.3 link_text
link=新闻
2.4 partial_link_text
partial link=新
2.5 class_name
class=s_ipt
2.6 tag_name
tag=input
2.7 xpath
2.7.1 绝对路径定位
该方式几乎不使用
2.7.2 相对路径定位
//form/span/input
2.7.3 元素属性定位
//input[@autocomplete="off"]
//input[@autocomplete="off" and @class="s_ipt"]
2.7.4 部分属性定位
//input[starts-with(@autocomplete,"of")]
//input[contains(@autocomplete,"of")]
6.7.5 文本定位
xpath=//a[text()="新闻"]
2.8 css
2.8.1 绝对路径定位
该方式几乎不使用
2.8.2 通过ID或者class定位
# id
.class
2.8.3 元素属性定位
input[autocomplete="off"]
input[autocomplete="off"][class="s_ipt"]
2.8.4 部分属性定位
input[autocomplete^="of"]
input[autocomplete$="of"]
input[autocomplete*="of"]
2.8.5 子元素定位
div#s-top-left a:nth-child(3)
\