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脚本编写