- 百度搜索實例
*** 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關鍵字.