我是QTP的新手。
我需要使用QTP测试Web应用程序。出于学习目的,我使用了Gmail登录页面,使用下面的脚本
Systemutil.Run "http://www.gmail.com"
Browser("Title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=Email").Set "xxxxxx"
Browser("Title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=Passwd").Set "yyyyyy"
Browser("Title:=Gmail.*").Page("title:=Gmail.*").WebButton("name:=Sign in").click
Gmail页面打开后,没有任何事情发生,也会发生一次错误
Cannot find the "[ WebEdit ]" object's parent "[ Browser ]" (class Browser). Verify that parent properties match an object currently displayed in your application.
Line (2): "Browser("Title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=Email").Set "xxxxxx"".
Tip: If the objects in your application have changed, the Maintenance Run Mode can
help you identify and update your steps and/or the objects in your repository.
答案 0 :(得分:1)
同时检查您的浏览器是否受QTP版本的支持!
答案 1 :(得分:1)
使用此结构更专业:
你所做的每个模块:
并享受。
答案 2 :(得分:0)
错误消息告诉您QTP无法识别您选择的“标题”标识符所指定的浏览器。
假设在GMail时浏览器的标识属性是正确的,最可能的原因是在您尝试执行.Set之前页面尚未完成加载(因此浏览器标题不会是“Gmail:”。 ..“还没有。”
以这种方式识别浏览器不是很灵活。尝试这样的东西代替浏览器识别:
Browser("application version:=internet explorer 8") 'though I don't really recommend this way of identifying either.
使用与页面无关的方式识别浏览器,然后您可以在打开浏览器后添加Sync语句:
Systemutil.Run "http://www.gmail.com"
Browser("application version:=internet explorer 8").Sync
Browser("application version:=internet explorer 8").Page("title:=Gmail.*").WebEdit("name:=Email").Set "xxxxxx" 'If you want to use "title" as an identifier here it'll probably work fine after the sync.
其他一些事项要检查它是否真的不是同步问题:
答案 3 :(得分:0)
您使用的描述看起来不错(我尝试了它,它适用于我)。我建议尝试使用 Object Spy 工具确认QTP是否正确注入浏览器,并且您的描述与现有浏览器的描述相匹配。