【QTP】Page对象:获取页面的链接和图片的个数

本文介绍了一种使用特定脚本语言来获取Web页面中的链接和图片数量的方法,并演示了如何点击链接并等待页面加载完毕。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Page对象是页面的主体对象,用于包含各种Web控件,通过Page对象,可以访问下一层次的对象,例如页面的链接、图片等。
下面的例子就是获取页面中还包含的链接和图片的个数

Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").Link("REGISTER").Click

'等待浏览器完成当前导航动作,用于模拟用户等到页面加载完成的过程
browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").Sync<wbr style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left"><br style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left"><span style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(229,231,231)">linksCount = browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").Object.links.length</span><br style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left"><br style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left"><span style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(229,231,231)"></span><wbr style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left"><span style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(229,231,231)">print "链接总共有:" &amp; linksCount</span><br style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left"><br style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left"><span style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(229,231,231)">ImagesCount = browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").Object.images.length</span><br style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left"><br style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left"><span style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(229,231,231)"></span><wbr style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left"><span style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(229,231,231)">print "图片总共有:" &amp; ImagesCount</span><br></wbr></wbr></wbr>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值