VerifyText Present
上一篇 /
下一篇 2012-11-16 16:46:46
/ 个人分类:selenium
今天在录制IDE的时候最后加了一个验证可一直结果是false,然后尝试了几次都不正确。
最后发觉我在页面右键选择VerifyTextPresent之后,他把要验证的值直接默认放在了Target,因此得手动把要验证的值输入到Value才行。
Assertion和Verification:
他们都是为了方便捕捉到failures,然而Effectively an “assert” will fail the
test and abort the current test case, whereas a “verify” will fail the test and continue to run the test case.
可以再一个assert后面跟多个verify,例如:
Command | Target | Value |
---|
open | /download/ | |
assertTitle | Downloads | |
verifyText | //h2 | Downloads |
assertTable | 1.2.1 | Selenium IDE |
verifyTable | 1.2.2 | June 3, 2008 |
verifyTable | 1.2.3 | 1.0 beta 2 |
加载完一个页面后先添加一个assert看下这个页面加载的正确不,如果不正确就可以直接退出这个test case,如果pass再执行verify可以判断下当前的文本位置出现是否正确。就算verify为fail此test case仍然可以继续执行。
常用的三个verify命令:
verifyTextPresent:验证特定的文本是否存在页面某处。
Command | Target | Value |
---|
verifyTextPresent | Marketing Analysis | |
verifyElementPresent:测试存在制定的UI元素,而不是他的内容的时候。
One common use is to check for the presence of an image.
Command | Target | Value |
---|
verifyElementPresent | //div/p/img | |
VerifyText:文本和UI的时候一块
测试的时候,
verifyTextmust use a locator.
Command | Target | Value |
---|
verifyText | //table/tr/td/div/p | This is my text and it occurs right after the div inside the table. |
收藏
举报
TAG: