Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a variable list to use throughout my scripts
#1
Not Solved
I have been trying a few different way to create and use a list of variables throught my tests and scripts. I must be doing something wrong as the variables disapear as the Library is left.

Currently, from my Test script, I call a function as below:

Code:
Public Function ImageAccessVariableList ()

Set objQTPApp  = CreateObject("QuickTest.Application")
Set objQTPLibraries = objQTPApp.Test.Settings.Resources.Libraries
If objQTPLibraries.Find("O:\QTP Tests\Objec Repository\ImageAccessVariableList.txt") <> -1 Then
    objQTPLibraries.Remove "O:\QTP Tests\Objec Repository\ImageAccessVariableList.txt"
    Reporter.ReportEvent micFail, "Image Access Variable List"& DataTable.GlobalSheet.GetCurrentRow, "The 'ImageAccessVariableList.txt' file was Not found.")
    ExitTestIteration
End If

End Function
What should i change?
Reply
#2
Not Solved
I tried the following, also with no luck.
(can i even set my variables from a Function call?

Code:
Public Function ImageAccessVariableList ()

'for "O:\QTP Tests\Objec Repository\ImageAccessVariableList.vbs"

Set objQTPApp  = CreateObject("QuickTest.Application")
objQTPApp.Launch
objQTPApp.Visible = True
Set objQTPLibraries = objQTPApp.Test.Settings.Resources.Libraries
'objQTPLibraries.RemoveAll

VariableList = "O:\QTP Tests\Objec Repository\ImageAccessVariableList.txt"

If objQTPLibraries.Find(VariableList) <> -1 Then
    objQTPLibraries.RemoveAll
    Reporter.ReportEvent micFail, "Variable List", "The ImageAccessVariableList.txt file was Not found."
    ExitTestIteration
End If

objQTPLibraries.Add (VariableList)
'objQTPLibraries.Add "D:\test2.vbs"

Reporter.ReportEvent micPass, "Variable List", "The ImageAccessVariableList.txt file was found."

Set objQTPApp = Nothing

End Function
Reply
#3
Not Solved
Not sure if i undestand the issue you're facing.. but, if you want to access variables stored externally to the test you can use a librarie (qfl) and declare the variables you need to use as public and associate the lib to the test, example:

'CONSTANTS FILE

'Creation Date: 07/02/2012
'Description: It Contains the path where the data source is located
Public Const DATA_SOURCE_PATH = "C:\Automation\DataSource\DataSource.xls"
Public Const IMPORT_DATA_SOURCE = True

'<<<<<<<<<<<< DATA MIGRATION >>>>>>>>>>>>>>>>
Code:
Public Const DATA_MIGRATION_FILE_PATH = "C:\Automatizacion\PIB\DataMigration\"
Public Const TAB_BALANCE = "hubpib.Inquire is missing"
    Public Const TAB_BALANCE_ACCOUNT_SUMMARY = "hubpib.Inquire is missing"
    Public Const TAB_BALANCE_MY_TRANSFERS_OTHER_BANKS = "My transfers to other banks"
    Public Const TAB_BALANCE_SPEI_OPERATION = "SPEI Operations"
Reply
#4
Not Solved
Code:
'*HAPPY B'DAY LORENA*
VariableList = "O:\QTP Tests\Objec Repository\ImageAccessVariableList.txt"
Set objQTPApp = CreateObject("QuickTest.Application")
objQTPApp.Launch
objQTPApp.Visible = True
Set objQTPLibraries = objQTPApp.Test.Settings.Resources.Libraries
If objQTPLibraries.Find(VariableList) <> -1 Then
objQTPLibraries.RemoveAll
End if
objQTPLibraries.Add (VariableList)
Reporter.ReportEvent micPass, "Variable List", "The ImageAccessVariableList.txt is freshly attached"
Set objQTPApp = Nothing
Reply
#5
Not Solved
Thx guys for your help. I will try both ideas.

Where do I place the code? in a function library?

Rajpes, thx for the B-Day wish. How did you know.? ;-)
Reply
#6
Not Solved
somehow i came to know Smile

You are creating instance of qtp app, so you cant put that in a function library.
Reply
#7
Not Solved
I added the code to a function library, but when i return to the Test script, the values in my txt file disapear.

objQTPLibraries.Add (VariableList) -- This code gives me a Run Error of "This operation cannot be preformed durring a run session."
Reply
#8
Not Solved
I went to Setup -> Resources sand added my vbs file

and, ,Itried:

Code:
Public Function ImageAccessVariableList ()
ExecuteFile  "O:\QTP Tests\QTPInputData\ImageAccessVariableList.vbs"
End function

But none of my variables get loaded into my QTP variable list.

thoughts?
Reply
#9
Not Solved
Rajpes,

Sorry, i just learned your meaning of "instance" of QTP.

How do I then run this instance of QTP? I was thinking of just adding my variable list to my test via File -> Settings -> Resources -> [+]

but from what I understand, I must start QTP using the code provided before the test runs?

If so, then it is not possible to load a variable list at the start of a test after QTP has been running?

thx for your advise.
Reply
#10
Not Solved
this should work. what do you meant by QTP variable list? can you share ImageAccessVariableList.vbs file.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need Excel template for mapping manual scripts to Automation scripts. ACCBAJPA 0 2,830 09-19-2013, 03:02 PM
Last Post: ACCBAJPA
  Creating Random String SomeIntern 0 4,764 08-21-2013, 09:10 PM
Last Post: SomeIntern
  Problem in creating excel object kriday 1 2,194 07-13-2013, 12:45 PM
Last Post: Ankur
  Creating multiple lines under a header - SAP Fredodo 7 5,315 01-02-2013, 04:54 PM
Last Post: Saleel Prabhu
Shy Resetting a variable list vbs file mv8167 0 1,979 11-03-2012, 12:23 AM
Last Post: mv8167

Forum Jump:


Users browsing this thread: 1 Guest(s)