【RobotFramework】Selenium2Library类库关键字使用说明

Add Cookie
Arguments:[ name | value | path=None | domain=None | secure=None | expiry=None ]
Adds a cookie to your current session. "name" and "value" are required, "path", "domain" and "secure" are optional

说明:暂未使用过,待补充......

Alert Should Be Present
Arguments:[ text= ]
Verifies an alert is present and dismisses it.
If `text` is a non-empty string, then it is also verified that the message of the alert equals to `text`.
Will fail if no alert is present. Note that following keywords will fail unless the alert is dismissed by this keyword or another like `Get Alert Message`.

说明:通过弹出框Alert的文本内容,判断弹出框Alert是否存在。

例子:Alert Should Be Present | 保存成功

Assign Id To Element
Arguments:[ locator | id ]
Assigns a temporary identifier to element specified by `locator`.
This is mainly useful if the locator is complicated/slow XPath expression. Identifier expires when the page is reloaded.

说明:分配ID给缺少ID的元素。

例子:Assign Id To Element | //div[@class=‘textarea-clear-btn‘] | ClassID01

Call Client Method For Element
Arguments:[ locator | jsMethodName | *args ]
Call client method for element identified by `locator`.

说明:暂未使用过,待补充......

Capture Page Screenshot
Arguments:[ filename=None ]
Takes a screenshot of the current page and embeds it into the log.
`filename` argument specifies the name of the file to write the screenshot into. If no `filename` is given, the screenshot is saved into file `selenium-screenshot-<counter>.png` under the directory where the Robot Framework log file is written into. The `filename` is also considered relative to the same directory, if it is not given in absolute format.
`css` can be used to modify how the screenshot is taken. By default the bakground color is changed to avoid possible problems with background leaking when the page layout is somehow broken.

说明:捕捉网页截图。可为截图命名或使用默认名(selenium-screenshot-<counter>)在指定截图保存目录下。

例子:Capture Page Screenshot | 截图20160925001

Checkbox Should Be Selected
Arguments:[ locator ]
Verifies checkbox identified by `locator` is selected/checked.
Key attributes for checkboxes are `id` and `name`. See `introduction` for details about locating elements.

说明:验证复选框已被选中/勾选。

例子:Checkbox Should Be Selected | CheckBoxIDorName

Checkbox Should Not Be Selected
Arguments:[ locator ]
Verifies checkbox identified by `locator` is not selected/checked.
Key attributes for checkboxes are `id` and `name`. See `introduction` for details about locating elements.

说明:验证复选框未被选中/勾选。

例子:Checkbox Should Not Be Selected | CheckBoxIDorName

Choose Cancel On Next Confirmation
Arguments:[ ]
Cancel will be selected the next time `Confirm Action` is used.

说明:在含“确定/取消”的弹出框中选择“取消”,需要与关键字(Confirm Action)组合使用。

例子:

Choose Cancel On Next Confirmation

Confirm Action    #选择“取消”

Choose File
Arguments:[ locator | file_path ]
Inputs the `file_path` into file input field found by `identifier`.
This keyword is most often used to input files into upload forms. The file specified with `file_path` must be available on the same host where the Selenium Server is running.

说明:选择文件。在上传页面,直接使用该关键字。或与关键字(get file)组合使用。

例子:

choose file | xpath=//div[@class=‘pd6 dot fcb‘]/span/input | C:\\Documents and Settings\\xxx\\My Documents\\My Pictures\\bug5.png

choose file | get file | C:\\Documents and Settings\\xxx\\My Documents\\My Pictures\\bug5.png

Choose Ok On Next Confirmation
Arguments:[ ]
Undo the effect of using keywords `Choose Cancel On Next Confirmation`. Note that Selenium‘s overridden window.confirm() function will normally automatically return true, as if the user had manually clicked OK, so you shouldn‘t need to use this command unless for some reason you need to change your mind prior to the next confirmation. After any confirmation, Selenium will resume using the default behavior for future confirmations, automatically returning true (OK) unless/until you explicitly use `Choose Cancel On Next Confirmation` for each confirmation.
Note that every time a confirmation comes up, you must consume it by using a keywords such as `Get Alert Message`, or else the following selenium operations will fail.

说明:在含“确定/取消”的弹出框中选择“确定”。

例子:Choose Ok On Next Confirmation

Click Button
Arguments:[ locator ]
Clicks a button identified by `locator`.
Key attributes for buttons are `id`, `name` and `value`. See `introduction` for details about locating elements.

说明:点击按钮。需要注意点击对象必须是button,而非图片、超链接、input。

例子:Click Button| ButtonOK

Click Element
Arguments:[ locator ]
Click element identified by `locator`.
Key attributes for arbitrary elements are `id` and `name`. See `introduction` for details about locating elements.

说明:点击元素。可运用在任何需要点击的元素上:按钮、图片、文字、超链接等。

例子:Click Element | xpath=//input[@value=‘百度一下‘]    #点击【百度一下】按钮

时间: 2024-11-05 01:56:38

【RobotFramework】Selenium2Library类库关键字使用说明的相关文章

robotframework + selenium2library 一点测试的经验

1 对于元素的外层包括frame/iframe标签的.一定要先select  frame name=xxx,然后再操作元素. Select frame name=新建个案 click element  id=  xxxxx 2 对于window.showModalDialog()模式打开的新窗口 Eg.点击"支付详情"的"详情",出来一个新页面.如何定位呢?单纯的select window title=payDetail page  是定位不到新窗口的.解决办法如下

robotframework+Selenium2Library 特殊下拉框的选择

4 特殊下拉框的选择   对于这种下拉框,一拉啥没有. 代码中也没有任何可操作的select option标签等.如何是好. 既然下拉框,那就总可以选择.我们输入一个名“王XX”,下拉框自动出现这样. 但是怎么选择上?代码实在没有相应的元素来操作啊. 不过,我们操作键盘,向下键,enter键,即可成功选择. 那问题就变成如何在robotframework+selenium2library中操作键盘.api给的很简单,press key  xxxx. 查了向下键的ascii为40,enter键的为

RobotFramework:python+robotframework+selenium2library测试环境部署说明文档

[来自组内整理文档] 一.部署环境准备 操作系统:Win7-64位或win7-32位或win10-64位 内存:DDR3, 4GB以上 运行环境:JDK1.8环境 安装jdk1.8.0_101 Java环境变量-系统变量配置 JAVA_HOME,配置为jdk安装地址 Classpath配置为 .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar; Path变量值后面加上 ;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin 运行cmd.exe

RobotFramework --Resources创建关键字文件

RIDE是robotframework的图形操作前端,我们在RIDE上进行测试用例设计和编写测试脚本,并执行自动化测试.下面来全面的认识下这个操作工具. 在右边编辑页面有三大模块,Edit,TextEdit,Run Edit页签     测试项目和测试套件的Edit是一样的   之前我们导入相关的库就是在Edit页签下导入库 导入外部文件: Add Library: 导入测试库,主要是\Lib\site-packages这个目录下面的库 Add Resource:导入相关资源,跟项目相关的一些资

robotframework+Selenium2Library 模态窗口的处理

所谓模态窗口,就是指除非采取有效的关闭手段,用户的鼠标焦点或者输入光标将一直停留在其上的对话框.(说白了,就是弹出了模态窗口之后,后面的窗口无法被点击) 这里有个demo页面http://www.robotframework.net/ ... alogA 对于window.showModalDialog()模式打开的新窗口 Eg.点击“支付详情”的“详情”,出来一个新页面.如何定位呢?单纯的select window title=payDetail page  是定位不到新窗口的.解决办法如下:

python3关键字使用说明

如图所示 一共33个关键字,其中False,None,True为首字母大写,其余均为小写. 1, False: 布尔值假,常用作返回值,或者条件判断时.数字0和空集属于False. 2, None: 先放着,以后补充. 3, True:布尔值真,常用作返回值,或者条件判断时.非0数字和非空集合属于True. 4, and:连接两个表达式 . 相当于逻辑与. if age>10 and age<20 5, as:  给引入的模块取个新的的名字.函数中引用模块的名字使用自定义名字. import

RF中selenium2Library的关键字--Elements

1.Click Button 2.Click Element 3.Click link 4.Click image 5.press key 6.Get Horizontal Position   :获取对象的左上角的横坐标 7.Get Vertical Position :获取对象的左上角的纵坐标 ${x} Get Horizontal Position id=nloginpwd ${y} Get Vertical Position id=nloginpwd 8.Get text.Get val

java中final关键字使用说明

必须在域的定义处或者每个构造器中用表达式对final进行赋值,这正是final域在使用前总是被初始化的原因所在. 版权声明:本文为博主原创文章,未经博主允许不得转载.

robotframework Excel Library关键字

Keywords Keyword Arguments Documentation Add New Sheet newsheetname Creates and appends new Excel worksheet using the new sheet name to the current workbook. Arguments: New Sheet name (string) The name of the new sheet added to the workbook. Example: