一个奖励100分的QTP的题目,来帮帮我!

来源:百度知道 编辑:UC知道 时间:2024/07/05 03:06:31
题目:请试使用QTP完成下述测试过程:

打开搜狗网页(http://www.sogou.com/features/weather.jsp);

随机点击网页中下方的城市链接;

获取该城市当日的天气情况,将其输出在DataTable中;

举例,QTP随机点击到下面“更多城市”--“上海”后,将其中的天气“中雨”和气温“6-8℃”输出到DataTable中。

本题不要求采用循环。
以下是以前某人写的脚本,不过有一些错误,希望高手帮我修改下!谢谢了!

dim city
city=DataTable("deportment", dtGlobalSheet)
Browser("搜狗特色功能——天气预报").Page("搜狗特色功能——天气预报").Link("innertext:="&city).Click
dim max, min, weather
max=Browser("搜狗特色功能——天气预报").Page("搜狗特色功能——天气预报").WebTable("class:=threeday").GetCellData(2,2)
min=Browser("搜狗特色功能——天气预报").Page("搜狗特色功能——天气预报").WebTable("class:=threeday").GetCellData(2,3)
weather=Browser("搜狗特色功能——天气预报").Page("搜狗特色功能——天气预报").WebTable("class:=threeday").GetCellData(2,4)
msgbox

还是我来吧,不知道能不能满足你的需求

SystemUtil.CloseProcessByName "iexplore.exe" '关闭以前打开的IE
'打开一个新的IE,"C:\Program Files\Internet Explorer\iexplore.exe" 是你本地IE的绝对路径
SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe","http://www.sogou.com/features/weather.jsp"
Set city=Description.Create()
city("micclass").Value="Link"
Set citylink=Browser("creationtime:=0").Page("index:=0").ChildObjects(city)
linkcount=citylink.Count
Dim cityname(400)
Dim h
h=0
For i=0 to linkcount-1
namehref=citylink(i).GetROProperty("href")
linkname=citylink(i).GetROProperty("innertext")
If mid(namehref,1,48)="http://www.sog