转:文本检查点在不使用对象库情况下的校验

本文介绍两种网页元素内容校验方法:一是通过webelement的innertext属性结合checkproperty方法进行完整内容或部分通配符校验;二是利用GetROProperty方法获取innertext属性值并对比预期值。

1.通过webelement的innertext 属性的checkproperty方法进行校验
a.进行完整内容的校验:
browser("title:=.*").page("http://hi.baidu.com/fc/editor/=.*%22).webelement(%22innertext:=收件夹空间使用"+cstr(msgnum)+"/200","html tag:=DIV","index:=2").CheckProperty "innertext","收件夹空间使用"+cstr(msgnum)+"/200",2

b.给出完整的内容校验,却没有办法获取实际值时,可以使用通配符".*"
browser("title:=.*").page("http://hi.baidu.com/fc/editor/=.*%22).webelement(%22innertext:=.*站内信.*","html tag:=LI").CheckProperty "innertext","站内信("+cstr(msgnum)+")",2

2.通过webelement的GetROProperty方法获取innertext属性的值,然后和预期值进行比较
strMessage = trim(browser("title:=.*").page("http://hi.baidu.com/fc/editor/=.*%22).webelement(%22innertext:=.*站内信.*","html tag:=LI").GetROProperty("innertext"))
msgnum=2 '是个变量,实际为根据数据库查询获取的总记录数
If strMessage = "站内信("+cstr(msgnum)+")" Then
         reporter.ReportEvent micPass, "成功", "期望是: 站内信("+cstr(msgnum)+"),实际是: "+cstr(strMessage)
else
         reporter.ReportEvent micFail, "失败", "期望是: 站内信("+cstr(msgnum)+"),实际是: "+cstr(strMessage)
End If

转载于:https://www.cnblogs.com/vinyfeng/articles/1341412.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值