Selenium IDE整理

安装

Step1: 下载Firefox浏览器

http://www.firefox.com.cn/

Step2: 安装Selenium IDE插件

http://seleniumhq.org/download/

Step3: 搜索 firebug并安装

https://addons.mozilla.org/firefox/addon/1843

适用性

  • create quick bug reproduction scripts
  • create scripts to aid in automation-aided exploratory testing

优点

  1. 简单,非自动化测试人员也可以用
  2. 录制好的脚本可以导出为其他语言的脚本(Export Test Case As):C#,Java,Python,Ruby。
  3. New Test Case/Test Suite
  4. Export Test Result/Test Case
  5. Insert Breakpoint
  6. Execute step by step
  7. Log
  8. Reference
  9. Schedule tests to run periodically

缺点

  1. 只能在火狐上用。
  2. 使用Selenium语言,缺乏逻辑控制语句,不能编写复杂的case。

定位方式

  • id=id
  • name=name
  • identifier=id/name 

首先查找HTML中是否存在该id的元素,若不存在,则查找第一个该name的元素

  • dom =  JavaScriptExpression dom locator

用JavaScript 表达式来定位HTML 中的元素,注意必须要以"document"开头

     例如:

     dom=document.forms['myForm'].myDropdown

     dom=document.images[56]

  • xpath=xpathExpression

     xpath locator 用XPath 表达式来定位HTML 中的元素,必须注意要以"//"开头

     例如:

     xpath=//img[@alt='The image alt text']

     xpath=//table[@id='table1']//tr[4]/td[2]

  • link=textPattern

     link locator 用link 来选择HTML 中的连接或锚元素

     例如:  link=The link text

在没有locator 前序的情况下如果以"document."开头,则默认是使用dom locator,如果是以"//"开头,则默认使用xpath locator,其余情况均认作identifier locator

 命令

在Command的下拉列表中,可以看到很多selenium语言命令。具体用法可以参考:Selenium_中文API

主要是操作命令+判断命令

判断命令主要以verify或者assert开头:assertElementPresent,verifyElementNotPresent等

原文地址:https://www.cnblogs.com/miniren/p/4979988.html