- 百度搜索实例
*** Settings ***
Documentation Simple example using SeleniumLibrary.
Library SeleniumLibrary
*** Test Cases ***
Baidu search case
Open Browser https://www.baidu.com chrome
Input text id:kw selenium
click button id:su
Evaluate time.sleep(2) time
${title} Get Title
should contain ${title} selenium_百度搜索
close Browser
其中sleep为Python所提供的休眠方法.Get Title获得搜索之后的页面标题,通过should contain关键字来断言标题是否正确.
- 126邮箱登录实例
*** Settings ***
Documentation Simple example using SeleniumLibrary.
Library SeleniumLibrary
*** Test Cases ***
Mail login case
Open Browser http://www.126.com chrome
Evaluate time.sleep(3) time
Select Frame xpath=//*[@id="x-URS-iframe"]
Input text name:email username
Input text name:password 123456
click element id:dologin
Unselect Frame
close Browser
这里主要使用了Select Frame关键字切换表单,登录按钮要用click element关键字.
网友评论