sunnyjia726 2008-6-19 16:34
WEB登录脚本,请各位指教
场景:
打开后台登录网站,输入用户名和密码
[table=50%][tr][td]用户名
[/td][td] 空[/td][td] admin[/td][td] 空[/td][td] aaa[/td][/tr][tr][td] 密码[/td][td] 空[/td][td] 空[/td][td] admin[/td][td] aaa[/td][/tr][/table]
用户名与密码的值使用了数据表参数,并将页面给出的提示语输出到数据表"Result"列中
Option Explicit
'定义变量
'userName 用户名
'usrPass 密码
'promptMessage 提示语
Dim usrName, usrPass,promptMessage
Browser("后台管理系统").Page("后台管理系统").WebEdit("user_name").Set DataTable("usrName", dtGlobalSheet)
usrName = Browser("后台管理系统").Page("后台管理系统").WebEdit("user_name").GetROProperty("Value")
Browser("后台管理系统").Page("后台管理系统").WebEdit("password").Set DataTable("usrPass", dtGlobalSheet)
usrPass=Browser("后台管理系统").Page("后台管理系统").WebEdit("password").GetROProperty("Value")
Browser("后台管理系统").Page("后台管理系统").Image("loginbutton1").Click
promptMessage = Browser("后台管理系统").Dialog("Microsoft Internet Explorer").Static("请输入密码!").GetROProperty("text")
DataTable("Result", dtGlobalSheet) = promptMessage
Browser("后台管理系统").Dialog("Microsoft Internet Explorer").WinButton("确定").Click
看到两周的书,写的第一个脚本,请各位大虾多多指导!
happychap 2008-6-19 16:52
promptMessage = Browser("后台管理系统").Dialog("Microsoft Internet Explorer").Static("请输入密码!").GetROProperty("text")
需要注意:在不同输入组合下Static对象用于QTP识别该对象的属性值是否发生变化,如果发生了变化,需要进行相应的处理。
sunnyjia726 2008-6-19 17:16
感谢楼上happychap的回复,
注:版主我把贴子发错地方了,不应放在精华区里的,帮我移到[QuickTest Pro]下面好啊?
对于windows的提示框我用对象探测器控探测了,发现该页面上弹出的所有的提示框在QTP里认为等同于一个对象,我用描述性编程修改了一下,
promptMessage = Browser("号百后台管理系统").Dialog("Microsoft Internet Explorer").Static("window id:= 65535","nativeclass:=Static").GetROProperty("text")
不知道是否有更好的方法解决。
[[i] 本帖最后由 sunnyjia726 于 2008-6-19 17:19 编辑 [/i]]
sunnyjia726 2008-6-20 11:35
贴子都沉了噢。。各位大虾们进来看看,给些意见吧