当使用QTP时,我们有可能需要判断一个网页上的图片是否是.jpg, .gif等扩展名结尾的,以下是判断扩展名的解决方案:
1. 我们使用Mercury 的demo应用 http://newtours.demoaut.com/. image
2. 需要检查的图片就是上面红色椭圆里面的图片
3. 现在”Object spy”上面那个image对象
4. 找到包含文件名的属性。通常这个属性的名字就是filename. 在这个例子中她的值是featured_destination.gif.
5. 把这个值通过GETTO属性放到一个数组中
6. 使用split函数来分割,以”.”为分割符
7. 数组的最后一个值就应该是你的文件扩展名
以下是实例代码:
Dim filename, arrfile
‘Put filename into the array
filename = Browser(“Welcome: Mercury Tours”).Page(“Welcome: Mercury Tours”).Image(“Featured Destination:”).GetTOProperty(“file name”)
msgbox arrfile(Ubound(arrfile))
评论列表
文章目录