常用命令(3)---Assertion(selenium学习笔记(一)seleniumIDE)

1、Assertion命令的3种模式:assert、verify、waitFor

assert-失败,测试中断

verify-失败,记录失败并继续执行测试

waitFor-用于执行等待,直到等待的条件为真,测试通过。设置超时setTimeOut,等待条件为假,测试失败并终止。

 

2、常用的Assertion命令:

 

-验证网页的标题是否等于或不等于预期值

assertTitle(parttern)/assertNotTitle(parttern)/verifyTitle(parttern)/verifyNotTitle(parttern)/waitFortTitle(parttern)/waitForNotTitle(parttern)

 

-验证网页的url是否等于或不等于预期值

assertLocation(parttern)/assertNotLocation(parttern)/verifyLocation(parttern)/verifyNotLocation(parttern)/waitForLocation(parttern)/waitForNotLocation(parttern)

 

-验证input元素的值是否等于或不等于预期值

assertValue(locator,parttern)/assertNotValue(locator,parttern)/verifyValue(locator,parttern)/verifyNotValue(locator,parttern)/waitForValue(locator,parttern)/

waitForNotValue(locator,parttern)

 

-验证input元素的可编辑状态是否为预期状态

assertEditable(locator)/assertNotEditable(locator)/verifyEditable(locator)/verifyNotEditable(locator)/waitForEditable(locator)/waitForNotEditable(locator)

 

-验证某个元素的文本值是否等于预期值

assertText(locator,parttern)/assertNotText(locator,parttern)/verifyText(locator,parttern)/verifyNotText(locator,parttern)/waitForText(locator,parttern)/

waitForNotText(locator,parttern)

 

-验证复选框或单选框的勾选情况是否符合预期

assertChecked(locator)/assertNotChecked(locator)/verifyChecked(locator)/verifyNotChecked(locator)/waitForChecked(locator)/waitForNotChecked(locator)

 

-验证所选项在列表中的索引是否符合预期值(从0开始)

assertSelectedIndex(selectLocator,parttern)/assertNotSelectedIndex(selectLocator,parttern)/verifySelectedIndex(selectLocator,parttern)/verifyNotSelectedIndex(selectLocator

,parttern)/waitForSelectedIndex(selectLocator,parttern)/waitForNotSelectedIndex

(selectLocator,parttern)

 

-验证指定列表中索选项的文本值是否符合预期值

assertSelectedLabel(selectLocator,parttern)/assertNotSelectedLabel(selectLocator,parttern)/verifySelectedLabel(selectLocator,parttern)/verifyNotSelectedLabel

(selectLocator,parttern)/waitForSelectedLabel(selectLocator,parttern)/

waitForNotSelectedLabel(selectLocator,parttern)

 

-验证指定列表中所选项的真实值(value属性)是否为预期值

assertSelectedValue(selectLocator,parttern)/assertNotSelectedValue(selectLocator,parttern)/verifytSelectedValue(selectLocator,parttern)/verifyNotSelectedValue

(selectLocator,parttern)/waitForSelectedValue(selectLocator,parttern)/

waitForNotSelectedValue(selectLocator,parttern)

 

-验证指定列表中所有选项的文本是否符合预期值

assertSelectedOptions(selectLocator,parttern)/assertNotValue(selectLocator,parttern)/verifytValue(selectLocator,parttern)/verifyNotValue(selectLocator,parttern)/waitFortValue(selectLocator,parttern)/

waitForNotValue(selectLocator,parttern)

 

-验证表格(table元素)中某个单元格(td元素)的值是否为预期值

assertTable(tableCellAddress,parttern)/assertNotSelectedOptions(tableCellAddress,parttern)/verifySelectedOptions(tableCellAddress,parttern)/verifyNotSelectedOptions

(tableCellAddress,parttern)/waitForSelectedOptions(tableCellAddress,parttern)/

waitForNotSelectedOptions(tableCellAddress,parttern)

 

-验证指定属性的值是否为预期值

assertAttribute(attributeLocator,parttern)/assertNotAttribute(attributeLocator,parttern)/verifyAttribute(attributeLocator,parttern)/verifyNotAttribute(attributeLocator,parttern)/waitForAttribute(attributeLocator,parttern)/

waitForNotAttribute(attributeLocator,parttern)

 

-验证指定的文本是否在页面中出现

assertTextPressent(parttern)/assertNotTextPressent(parttern)/verifyTextPressent(parttern)/verifyNotTextPressent(parttern)/waitFortTextPressent(parttern)/waitForNotTextPressent(parttern)

 

-验证指定元素是否存在于页面上

assertElementPresent(locator)/assertNotElementPresent(locator)/verifyElementPresent(locator)/verifyNotElementPresent(locator)/waitFortElementPresent(locator)/waitForNotElementPresent(locator)

 

-验证页面中是否显示指定元素

assertVisible(locator)/assertNotVisible(locator)/verifyVisible(locator)/verifyNotVisible(locator)/waitForVisible(locator)/waitForNotVisible(locator)

 

posted on 2018-06-27 10:27  老奶奶的小卖铺  阅读(483)  评论(0编辑  收藏  举报