关联步骤:
->Select File on your QTP menu
->Select Settings..
->Select "Resources" Tab
->Associated function libraries(click the + button)
->choose your vbs script作者: 论坛守护神 时间: 2009-10-7 15:38
我自己也是相当的奇怪呢,把代码贴到这里。麻烦给位给看看
为了避免混淆,test.vbs里面改为一句
public abc
Browser("Browser").Page("Page").Sync
If Browser("Browser").Page("Regulus View²").WebEdit("userName").Object.value <> "" Then
Browser("Browser").Page("Regulus View²").WebEdit("password").Object.value = "Test"
Browser("Browser").Page("Regulus View²").Link("Login").Click
else
Browser("Browser").Page("Regulus View²").WebEdit("username").Set "all"
Browser("Browser").Page("Regulus View²").WebEdit("password").SetSecure "4ac1bf21be03113115da983ae60af208e303a8cb386c"
Browser("Browser").Page("Regulus View²").Link("Login").Click
End If
Browser("Browser").Page("Page").Sync
'判断logout的值,如果成功则修改abc为1,标示登陆成功
If Browser("Browser").Page("Regulus View² - Home").WebElement("LOGOUT").GetROProperty("value") = "LOGOUT" then
Reporter.ReportEvent micFail,"Logon","Logon failed"
Parameter("FlaLogon") = false
Else
Reporter.ReportEvent micPass,"Logon","Logon successful"
abc = 1
Parameter("FlaLogon") = true
End if
跟踪看了一下,1是赋给了abc的,但是出来以后就没值了。
[ 本帖最后由 论坛守护神 于 2009-10-7 15:42 编辑 ]作者: Haereticus 时间: 2009-10-7 15:44
When you run an ExecuteFile statement within an action, you can call the functions in the file only from the current action. To make the functions in a VBScript file available to your entire test, add the file name to the associated function libraries list in the Resources tab of the Test Settings dialog box. For more information, see Working with Associated Function Libraries.作者: Haereticus 时间: 2009-10-7 15:45
When you run an ExecuteFile statement within an action, you can call the functions in the file only from the current action. To make the functions in a VBScript file available to your entire test, add the file name to the associated function libraries list in the Resources tab of the Test Settings dialog box. For more information, see Working with Associated Function Libraries.作者: 论坛守护神 时间: 2009-10-7 23:28
To Haereticus
我已经把test.vbs作为resource添加进主action和logon action了。。作者: Haereticus 时间: 2009-10-8 14:07
在你脚本里修改的值只是临时修改了abc的值,类似于一个局部变量,要修改abc的值你必须修改test.vbs文件里abc的值,然后重新执行ExecuteFile ("D:\test.vbs"),才会生效。其实全局变量的通常方法,一般是把变量保存在一个xml文件,这样可随时修改变量的值,然后再加载进来就OK了作者: dabeixiong 时间: 2009-10-8 23:04
恩~楼上说的在理...
我也看了下帮助:
If you decide not to associate a function library (any VBScript file) with a test, but do want to be able to call its functions, subroutines, and so forth from an action in your test or from another function library, you can do so by inserting an ExecuteFile statement in your action.