我正在尝试使用AOM设置环境变量
Set objFSO = CreateObject("Scripting.FileSystemObject")
curDir = objFSO.GetParentFolderName(WScript.ScriptFullName) & "\"
Set qtApp = CreateObject("QuickTest.Application")
If qtApp.Launched <> True Then
With qtApp
.Launch
.Visible = True
.Options.Run.RunMode = "Fast"
.Options.Run.ViewResults = False
.Open "C:\_Work\MAIN\TestDriver", False
Set qtTest = .Test
With qtTest
.Settings.Run.OnError = "NextStep"
.Settings.Resources.Libraries.RemoveAll
.Environment.LoadFromFile "C:\_Work\MAIN\Configuration\Test2.xml"
.Run
End With
End With
End If
在QTP脚本中,我使用的是用户定义的环境变量(如Test2.xml中所定义),但由于文件未加载,因此无法正常工作。我也检查了设置,没有用户定义的EV。
答案 0 :(得分:2)
我不确定它是否是来自UFT的错误或可能是我们遗漏了某些内容,但来自.vbs文件的 Environment.LoadFromFile
无效。
截至目前,解决方法是在UFT测试脚本中加载环境变量文件 - TestDriver
。
将此代码放在代码的顶部。
'Check if an External Environment file is loaded and if not, load it.
Dim fileName
fileName = Environment.ExternalFileName
If (fileName = "") Then
Environment.LoadFromFile("C:\_Work\MAIN\Configuration\Test2.xml")
End If
Msgbox Environment.Value("Your_Variable_Name")
...
'your rest of the code
如果您不想使用此路线,则可能需要与HP联系。
答案 1 :(得分:0)
Dim App 'As Application
Set App = CreateObject("QuickTest.Application")
App.Launch
App.Visible = True
App.Open "C:\Automation\OracleEBS", False
App.Test.Settings.Launchers("Java").Active = False
App.Test.Settings.Launchers("Java").CommandLine = ""
App.Test.Settings.Launchers("Java").WorkingDirectory = ""
App.Test.Settings.Launchers("Oracle").Active = False
App.Test.Settings.Launchers("Oracle").Address = ""
App.Test.Settings.Launchers("Oracle").AutoLogin = False
App.Test.Settings.Launchers("Oracle").User = ""
App.Test.Settings.Launchers("Oracle").Password = ""
App.Test.Settings.Launchers("Oracle").LogoutOnExit = False
App.Test.Settings.Launchers("Oracle").CloseOnExit = False
App.Test.Settings.Launchers("Web").Active = True
App.Test.Settings.Launchers("Web").Browser = "CHROME"
App.Test.Settings.Launchers("Web").Address = "http://newtours.demoaut.com "
App.Test.Settings.Launchers("Web").CloseOnExit = True
App.Test.Settings.Launchers("Windows Applications").Active = True
App.Test.Settings.Launchers("Windows Applications").Applications.RemoveAll
App.Test.Settings.Launchers("Windows Applications").RecordOnQTDescendants = True
App.Test.Settings.Launchers("Windows Applications").RecordOnExplorerDescendants = True
App.Test.Settings.Launchers("Windows Applications").RecordOnSpecifiedApplications = True
App.Test.Settings.Run.IterationMode = "rngAll"
App.Test.Settings.Run.StartIteration = 1
App.Test.Settings.Run.EndIteration = 1
App.Test.Settings.Run.ObjectSyncTimeOut = 20000
App.Test.Settings.Run.DisableSmartIdentification = False
App.Test.Settings.Run.OnError = "Dialog"
App.Test.Settings.Resources.DataTablePath = "<Default>"
App.Test.Settings.Resources.Libraries.RemoveAll
App.Test.Settings.Resources.Libraries.Add("C:\UFTAutomation\function_Libraray\FL.txt")
App.Test.Environment.LoadFromFile "C:\Users\uftuser01\Desktop\env.xml"
App.Test.Settings.Web.BrowserNavigationTimeout = 60000
App.Test.Settings.Web.ActiveScreenAccess.UserName = ""
App.Test.Settings.Web.ActiveScreenAccess.Password = ""
App.Test.Settings.Recovery.Enabled = True
App.Test.Settings.Recovery.SetActivationMode "OnError"
App.Test.Settings.Recovery.Add "C:\tmp\FRecovery.qrs", "First Recovery Scenario", 1
App.Test.Settings.Recovery.Item(1).Enabled = True
App.Test.Settings.Java.EditSet.KeyPressed = True
App.Test.Settings.Java.EditSet.KeyTyped = True
App.Test.Settings.Java.EditSet.KeyReleased = True
App.Test.Settings.Java.EditSet.InputMethod = False
App.Test.Settings.Java.EditSet.FocusLost = False
App.Test.Settings.Java.EditSet.JavaAPI = False
App.Test.Settings.Java.EditSet.JavaAPICharactersToExclude = "\t\n\r"
App.Test.Settings.Java.DeviceReplay.Click = False
App.Test.Settings.Java.DeviceReplay.DoubleClick = False
App.Test.Settings.Java.DeviceReplay.Type = False
App.Test.Settings.Java.DeviceReplay.DragDrop = False
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' System Local Monitoring settings
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
App.Test.Settings.LocalSystemMonitor.Enable = false
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Log Tracking settings
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
With App.Test.Settings.LogTracking
.IncludeInResults = False
.Port = 18081
.IP = "127.0.0.1"
.MinTriggerLevel = "ERROR"
.EnableAutoConfig = False
.RecoverConfigAfterRun = False
.ConfigFile = ""
.MinConfigLevel = "WARN"
End With