在第一講的時候,已經安裝了Selenium2Library這個庫,這一篇主要來整理介紹一下Selenium2Library中的經常使用關鍵字,爲咱們以後的web自動化打好基礎javascript
1.Open Browser 打開瀏覽器css
2.Close Browser 關閉瀏覽器java
3.Go to 轉到某個URLjquery
4.Go Back 至關於瀏覽器的後退web
5.Switch Browser 轉換瀏覽器 (參數是打開瀏覽器的index順序或者alias別名)瀏覽器
6.Close All Browsers 關閉全部的瀏覽器cookie
1.Select Window 選擇窗口異步
2.Wait Until Keyword Succeeds 等待直到關鍵詞成功async
3.Close Window 關閉窗口網站
4.Select Window Main 選擇主窗口
1.select window by handle 經過handle選擇窗口
2.get window handles 獲取當前線程全部窗口的handles,返回list
3.get current window handle 獲取當前窗口的handle
1.Select Frame 選擇frame
2.Unselect Frame 直接跳出全部的frame或iframe
cookie是網站爲了辨別用戶身份儲存在用戶本地的數據,可能涉及用戶名,密碼,訪問歷史等
1.add cookie 添加cookie
2.delete cookie 刪除cookie
3.delete all cookies 刪除全部cookie
4.get cookies 獲取全部cookie
5.get cookie value 獲取cookie的值
locator 元素定位器 :id,name,xpath,css,jquery,sizzle
1>click element 點擊元素
2>click link 點擊連接
3>click image 點擊圖片
4>press key 模擬鍵盤操做
5>Assign id to element 給某個元素指定id
6>mouse down 鼠標按下
7>mouse up 鼠標鬆開
8>mouse over 鼠標移入元素
9>mouse out 鼠標從某元素移出
10>Get horizontal position 獲取當前對象左上角頂點距離整個頁面的橫座標
11>Get vertical position 獲取當前對象左上角頂點距離整個頁面的縱座標
12>Get value 獲取網頁元素的value
13>get text 獲取網頁元素的text
14>get element attribute+關鍵字 獲取元素其餘屬性值
15>Page Should Contain 驗證頁面文本
form(表單),checkbox(複選框),radio buttons(單選按鈕),text fields(文本輸入框),button(按鈕)
1> submit form 提交表單
2>select checkbox 勾選複選框
3>unselect checkbox 不勾選複選框
4>select radio button 勾選單選按鈕
5>choose file 上傳文件的時候選擇文件
6>input text 輸入文本
7>input password 輸入密碼,在輸入密碼的日誌上不會把密碼打印出來
8>click button 點擊按鈕
1>select from list 選擇列表框的某一項
2>select from list by index 經過index來選擇列表項
3>select from list by value 經過value來選擇列表項
4>select from list by label 經過label來選擇列表項
5>select all from list 多選列表框所有選擇
6>unselect from list 取消選擇多選列表框的某一項
7>unselect from list by index 經過index來取消選擇多選列表項
8>unselect from list by value 經過value來取消選擇多選列表項
9>unselect from list by label 經過label來取消選擇多選列表項
10>get list items 獲取全部的列表項
11>get selected list label 獲取選擇的列表項的label值,多選默認取第一個
12>get selected list value 獲取選擇的列表項的value值,多選默認取第一個
13>get selected list labels 獲取全部選擇的列表項的label值
14>get selected list values 獲取全部選擇的列表項的value值
1>get table cell 獲取指定table裏的指定行列的元素的文本值
2>click element at table cell 點擊表格指定單元格里的元素
3>click link at table cell 點擊表格指定單元格里的連接
4>get index in table column 獲取某個文本在表格的哪一行
5>get index in table row 獲取某個文本在表格的哪一列
6>get table rows 獲取表格的行數
7>get table cols at row 獲取某一行表格有多少列
1.execute JavaScript 執行JavaScript腳本
2.execute async JavaScript 異步執行JavaScript腳本
3>confirm action 自動進行對話框的確認
4>choose cancel on next confirmation confirm action 對話框點擊取消
5>choose ok on next confirmation confirm action 對話框恢復默認點確認
capture page screenshot 對當前頁面進行截圖
1>wait for condition
2>wait until page contains
3>wait until page contains element