Selenium 命令列表

发表于:2007-11-22 13:45

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:未知    来源:网络转载

分享:

三、 Assertions
允许用户去检查当前状态。两种模式: Assert 和 Verify, 当Assert失败,则退出测试;当Verify失败,测试会继续运行。

assertLocation, assertTitle
assertLocation(relativeLocation)
判断当前是在正确的页面 verifyLocation  /mypage   
assertLocation  /mypage   

assertTitle(titlePattern)
检查当前页面的title是否正确 verifyTitle  My Page   
assertTitle  My Page   

assertValue
assertValue(inputLocator, valuePattern)
- 检查input的值
- 对于 checkbox或radio,如果已选择,则值为"on",反之为"off" verifyValue  nameField  John Smith 
assertValue  document.forms[2].nameField  John Smith 

assertSelected, assertSelectedOptions
assertSelected(selectLocator, optionSpecifier)
检查select的下拉菜单中选中的选型是否和optionSpecifer(Select选择选项器)的选项相同 verifySelected  dropdown2  John Smith 
verifySelected  dorpdown2  value=js*123 
assertSelected  document.forms[2].dropDown  label=J*Smith 
assertSelected  document.forms[2].dropDown  index=0 

assertSelectOptions(selectLocator, optionLabelList)
- 检查下拉菜单中的选项的文本是否和optionLabelList相同
- optionLabelList是以逗号分割的一个字符串 verifySelectOptions  dropdown2  John Smith,Dave Bird 
assertSelectOptions  document.forms[2].dropdown  Smith,J,Bird,D 

assertText
assertText(elementLocator,textPattern)
- 检查指定元素的文本
- 只对有包含文本的元素生效
- 对于Mozilla类型的浏览器,用textContent取元素的文本,对于IE类型的浏览器,用innerText取元素文本 verifyText  statusMessage  Successful 
assertText  //div[@id='foo']//h1  Successful 

assertTextPresent, assertAttribute
assertTextPresent(text)
检查在当前给用户显示的页面上是否有出现指定的文本 verifyTextPresent  You are now logged in   
assertTextPresent  You are now logged in   

assertAttribute(.{}elementLocator@attributeName.{}, ValuePattern)
检查当前指定元素的属性的值 verifyAttribute  txt1@class  bigAndBlod 
assertAttribute  document.images[0]@alt  alt-text 
verifyAttribute  //img[@id='foo']/alt  alt-text 

assertTextPresent, etc.
assertTextPresent(text)
assertTextNotPresent(text)
assertElementPresent(elementLocator)  verifyElementPresent    submitButton     
 assertElementPresent    //img[@alt='foo']      assertElementNotPresent(elementLocator) 

assertTable
assertTable(cellAddress, valuePattern)
- 检查table里的某个cell中的值
- cellAddress的语法是tableName.row.column, 注意行列序号都是从0开始 verifyTable  myTable.1.6  Submitted 
assertTable  results0.2  13 

32/3<123>
100家互联网大公司java笔试题汇总,填问卷领取~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2023
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号