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属性值
posted @ 2019-04-25 14:12  x3d  阅读(4116)  评论(0编辑  收藏  举报