找回密码
 立即注册

推荐阅读

  • 便民服务
  • 关注我们
  • 社区新手

selenium自动化,定位断言和添加关键字

[复制链接]
关键字:
万能的JS:
Execute Javascript   |  document.getElementById('HD_TxtKeyword').value='联友'
open browser                            打开浏览器
close browser                            关闭浏览器
close all browser                        关闭所有脚本打开的浏览器
Switch Browser                          切换到指定的浏览器
maximize browser windows        浏览器窗口最大化
sleep                                         休眠(/s)
wait until page contains                                等待元素加载完成立即往下运行
Wait Until Page Contains Element               等待页面包含元素,开始运行下一步
Wait Until Element Contains                         等待直到包含某些文字运行下一步
Wait Until Element Is Enabled.                     等待直到元素启用
Wait Until Element Is Not Visible                  等待直到页面元素不可见
Wait Until Element Is Visible.                       等待直到页面元素可见
Wait Until Element Does Not Contain        等待直到元素不包含
Wait Until Page Does Not Contain              等待直到页面不包含元素
input text                                   输入框输入文字
input password                          密码框输入密码
click link                                    点击链接
go to                                         去到指定链接
click img                                                         点击图片
click button                                                     点击按钮
clike radio button    sex    123(value值)     点击单选按钮
select from list by index
select from list by label
select from list by value
aseogn id to element         name=wd      yy
input text                            id=yy             多测师
select window   +new   +title          选择窗口
switch browser                              选择浏览器加别名
mouse over                                   鼠标移动到指定位置
select frame                                 选中iframe嵌套网页
Evaluate                               关键字之后可使用Python中的类和方法
log many                              直接打印列表中的所有元素

弹窗的定位
D:/DATA-biji/weixinobU7VjoAKFNW9YmuSpb5FgU5X--Q/4b8f1e630345481d90f2837da15e53b7/6bd62c97f6224585b142c5f4be8661b4.jpg
js弹窗
D:/DATA-biji/weixinobU7VjoAKFNW9YmuSpb5FgU5X--Q/889c6df20a294c9ab423a7feeea36a3a/12fe98689ef04704ab838061c6ffc434.jpg
然后点击页面空白处点击查看源代码,ctrl+f搜索 javascript,找到$()  这个标签
复制后在RF框架下Execute Javascript      +       $('.bigimg').hide();


断言
页面断言
Page should contain button                 页面应该包含按钮
Page should contain image                  页面应该包含图像
Page should contain link                     页面应该包含链接
Page should contain list                      页面应该包含列表
Page should contain radio button         页面应该包含单选按钮
Page should contain textfield               页面应该包含文本字段
Page should contain checkbox             页面应该包含复选框
Page should contain element               页面应该包含元素

Page Should Not Contain                     页面不应该包含
Page Should Not Contain Button           页面不应该包含按钮
Page Should Not Contain Checkbox       页面不应该包含复选框
Page Should Not Contain Element         页面不应该包含元素
Page Should Not Contain Image           页面不应该包含图像

表格断言
Get Table Cell:获取表格中的值
Table Cell Should Contain   表单元格应该包含,这里要指定行列
Table Column Should Contain    表列应该包含
Table Footer Should Contain    表页脚应该包含
Table Header Should Contain    表头应该包含
Table Row Should Contain   表行应该包含

Table Should Contain     表应该包含,有就行这里指整张表
Textarea Should Contain    文本框应该包含
Textarea Value Should Be    文本值应该


定义一个库写关键字
第一步:在python27\Lib\site-pakeage路径下新建一个目录,该目录为你的库民
第二步:在自己新建的目录里面新建2个文件  ".py" 和  "__init__.py"文件

__init__.py
# coding=utf-8
from function1 import mytool         #function1代表py文件名字
class gsf(mytool):                           #xiaochen:代表库名即文件夹名    mytool:代表类名
    ROBOT_LIBRARY_SCOPE = 'GLOBAL'

#注:ROBOT_LIBRARY_SCOPE = ‘GLOBAL’这一句代表库是全局的

分享至 : QQ空间
收藏

0 个回复

您需要登录后才可以回帖 登录 | 立即注册