QTP登录脚本

上一篇 / 下一篇  2008-09-24 12:00:11 / 天气: 台风的大雨及大风天气 / 心情: 平静 / 个人分类:QTP脚本编写

我要实现的需求:验证登录成功或失败,跳转的页面是否正确。

采用了参数化功能,以及判断语句if.....then

调试通过。

以sohu论坛登录为例。

脚本如下:

Dim right_str,error_str
'num=DataTable.GetSheet("Global").GetRowCount
'For i=1 to num
Browser("搜狐社区,中文第一社区-club.sohu.com").Navigate("http://club.sohu.com/")
Browser("搜狐社区,中文第一社区-club.sohu.com").Page("搜狐社区,中文第一社区-club.sohu.com").WebEdit("email").Set DataTable("username", dtGlobalSheet)
Browser("搜狐社区,中文第一社区-club.sohu.com").Page("搜狐社区,中文第一社区-club.sohu.com").webedit("password").SetSecure DataTable("EncryptedText", dtGlobalSheet)
Browser("搜狐社区,中文第一社区-club.sohu.com").Page("搜狐社区,中文第一社区-club.sohu.com").webbutton("登 录").Click
wait(3)
right_str=Browser("搜狐社区,中文第一社区-club.sohu.com").Page("搜狐社区,中文第一社区-club.sohu.com").WebElement("tewtewtet").Exist
error_str=Browser("搜狐社区,中文第一社区-club.sohu.com").Page("搜狐社区,中文第一社区-club.sohu.com").WebElement("用户名或密码错误").Exist
If  right_str Then
 msgbox"登录成功"
 Browser("搜狐社区,中文第一社区-club.sohu.com_2").Page("搜狐社区,中文第一社区-club.sohu.com").Link("退出").Click
 elseif error_str  then
 msgbox"登录失败"
End If


TAG: QTP脚本编写

 

评分:0

我来说两句

日历

« 2024-05-09  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 2719
  • 日志数: 4
  • 建立时间: 2008-01-14
  • 更新时间: 2008-12-30

RSS订阅

Open Toolbar