本帖子为本人原创,转载请注明作者:Cheers . Lee以及网络来源
需要解决的问题:
很多使用QTP的朋友用QTP测试Flash或Flex系统时,遇到flash对象被识别成了一个WinObject("非活动控件"),而对应也方法是通过定位鼠标焦点,然后执行相应的操作.例如:
Browser("FlexStore").Page("FlexStore").WinObject("MacromediaFlashPlayerActiveX").Click 109,98Browser("FlexStore").Page("FlexStore").WinObject("MacromediaFlashPlayerActiveX").Type "test"
Browser("FlexStore").Page("FlexStore").WinObject("MacromediaFlashPlayerActiveX").Click 210,102
Browser("FlexStore").Page("FlexStore").WinObject("MacromediaFlashPlayerActiveX").Click 503,312
这样录制的脚本,当然不能符合我们测试的要求.
针对此类问题的方法,就是要安装Flash插件:Flex2_Plugins_QuickTestPro
当然下载安装Flex2_Plugins_QuickTestPro方法我在上一篇QTP中Flex2_Plugins_QuickTestPro插件破解方法中,进行详细的介绍.
安装完Flex2_Plugins_QuickTestPro后,需要重启电脑.
重新打开QTP,在Add-In Manager中就可以看到已安装的Flex2.0.1插件.
如图:
或者在QTP菜单栏,Tools-Objects Identification...中Environment下拉列表中,可以看到Flex2.0.1插件,如图:
加载Flex2.0.1插件后,重新录制脚本,如下:
Browser("FlexStore").FlexApplication("flexstore").FlexToggleButtonBar("_ToggleButtonBar1").Change "Products"Browser("FlexStore").FlexApplication("flexstore").FlexToggleButtonBar("_ToggleButtonBar1").Change "Support"
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Support").FlexForm("index:4").FlexTextArea("Address::address").SelectText 0,0
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Support").FlexForm("index:4").FlexTextArea("Address::address").Input "上海浦东"
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Support").FlexForm("index:4").FlexTextArea("City::city").SelectText 0,0
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Support").FlexForm("index:4").FlexTextArea("City::city").Input "上海"
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Support").FlexForm("index:4").FlexComboBox("State::state").Open
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Support").FlexForm("index:4").FlexComboBox("State::state").Select "Nevada"
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Support").FlexForm("index:4").FlexTextArea("ZIP Code::zip").SelectText 0,0
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Support").FlexForm("index:4").FlexTextArea("ZIP Code::zip").Input "200323"
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Support").FlexButton("Locate").Click
Browser("FlexStore").FlexApplication("flexstore").FlexAlert("Locate").FlexButton("OK").Click
现在QTP对于Flash对象已经识别出来了,呵呵!下来的操作就和测试其他对象一样了.
你可以用Adobe提供的一个Flex网站测试.
网址: http://examples.adobe.com/flex2/inproduct/lcds/flexstore/flexstore.html
至此,问题解决!
文章来源于领测软件测试网 https://www.ltesting.net/