Selenium IDE 3.6 命令Command詳解


Selenium IDE 3.6 命令Command詳解

學以致用,個人覺得要學老外的東西,最好的方法就是自己翻譯一遍。因此准備把SIDE官網的一些文檔,按工作所需做些翻譯整理。本文是命令這一塊的提綱,未全部完成,占坑中,查看進度

Selenium IDE中的命令其實就等同於編程語言中的函數,這是首先要建立的一個概念。

函數是一個小的功能單元,每個函數都有自己目的,實現一個具體的功能,函數有入參、有出參。

要想用SIDE完成日常測試工作中各種場景的需求,就得熟練掌握這些命令,並靈活運用。

而要學會這些命令,前期得多看文檔,看看每個命令的作用是什么、傳什么參數,輸出什么結果。

對於Web領域測試人員來說,Web前端知識的要求還是有點高的,要了解HTML(標簽、id、class、屬性等)、CSS(元素選擇器selector)、Javascript/DOM、XML(xml、節點、元素、屬性、xpath等)

官網地址:https://www.selenium.dev/selenium-ide/docs/en/api/commands

Selenium IDE 目前的版本 3.6 系列,有90多個內置命令。這些可以分為如下幾類:

大類 小類 命令列表
工具類 -
  1. pause(wait-time):等待多長時間再執行
  2. set speed(wait-time):設置全局的操作執行速度
  3. run(test-case):運行測試用例
  4. echo(message):輸出信息到控制台
  5. debugger():進入調試環境
交互操作 窗口
  1. close():關閉當前窗口
  2. select frame(locator):選中frame
  3. select window(window-handle):選擇窗口
  4. set window size(resolution):設置窗口大小
頁面
  1. open(url):打開URL
  2. run script(script):運行一段js腳本
表單
  1. add selection(locator, value):select增加選擇項
  2. check(locator):checkbox/radio勾選
  3. edit content(locator, variable-name):編輯內容
  4. remove selection(locator, option):移除多選元素選擇項
  5. select(locator, option):選擇下拉項
  6. submit(form-locator):提交表單
  7. type(locator, value):模擬輸入input字段值
  8. uncheck(locator):取消勾選
彈框
  1. answer on next prompt(answer)
  2. choose cancel on next confirmation()
  3. choose cancel on next prompt()
  4. choose ok on next confirmation()
  5. webdriver answer on visible prompt(answer)
  6. webdriver choose cancel on visible confirmation()
  7. webdriver choose cancel on visible prompt()
  8. webdriver choose ok on visible confirmation()
鼠標
  1. click(locator):單擊元素
  2. click at(locator, coord string):單擊元素
  3. double click(locator)
  4. double click at(locator, coord string)
  5. drag and drop to object(locator-of-object-to-be-dragged, locator-of-drag-destination-object):拖拽對象
  6. mouse down(locator):模擬鼠標按鍵按下
  7. mouse down at(locator, coord-string):根據坐標模擬鼠標按鍵按下
  8. mouse move at(locator, coord-string)模擬鼠標移動到
  9. mouse out(locator):模擬鼠標移出
  10. mouse over(locator):模擬鼠標經過
  11. mouse up(locator):模擬鼠標按鍵放開
  12. mouse up at(locator, coord-string):根據坐標模擬鼠標按鍵放開
鍵盤
  1. send keys
流程控制 流程類
  1. do
  2. if
  3. else
  4. else if
  5. end
  6. repeat if
  7. while
  8. times
控制類
  1. wait for element editable
  2. wait for element not editable
  3. wait for element not present
  4. wait for element not visible
  5. wait for element present
  6. wait for element visible
變量類
  1. store(text, variable-name):將值存儲到變量中
  2. store attribute(attribute-locator, variable-name):將元素屬性值存儲到變量中
  3. store text(locator, variable-name):將文本存儲到變量中
  4. store title(text, variable-name):將標題存儲到變量中
  5. store value(value, variable-name):將元素value屬性值存儲到變量中
  6. store window handle(window-handle):存儲窗口操作句柄
  7. store xpath count(xpath, variable-name):存儲根據xpath方式匹配到的節點數
  8. execute script(script, variable-name):執行腳本
  9. execute async script(script, variable-name):執行異步腳本
斷言類 非阻斷型
  1. verify
  2. verify checked
  3. verify editable
  4. verify element present
  5. verify element not present
  6. verify not checked
  7. verify not editable
  8. verify not selected value
  9. verify not text
  10. verify selected label
  11. verify selected value
  12. verify text
  13. verify title
  14. verify value
阻斷型
  1. assert(variable-name, expected-value):斷言
  2. assert alert(alert-text):斷言警告框內容
  3. assert checked(locator):斷言被勾選狀態
  4. assert confirmation(text):斷言確認框
  5. assert editable(locator):斷言元素處於可編輯狀態
  6. assert element present(locator):斷言元素處於存在狀態
  7. assert element not present(locator):斷言元素不存在
  8. assert not checked(locator):斷言未被勾選狀態
  9. assert not editable(locator):斷言元素處於不可編輯狀態
  10. assert not selected value(locator, text):斷言非應選擇值
  11. assert not text(locator, text):斷言非預期文本內容
  12. assert prompt(text):斷言提示框
  13. assert selected value(select-locator, text):斷言應選擇值
  14. assert selected label(select-locator, text):斷言應選擇標簽
  15. assert text(locator, text):斷言文本內容
  16. assert title(text):斷言頁面標題
  17. assert value(locator, text):斷言value屬性值


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM