Micro Focus QTP (UFT) Forums
QTP AOM related Question - need solution - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: QTP AOM related Question - need solution (/Thread-QTP-AOM-related-Question-need-solution)



QTP AOM related Question - need solution - prodipto_dutta - 05-02-2011

I have QTP Fraemwork related query, I already developed a code which dynamically load repositories,add library file and it is working fine.
But while generating the code I came up with lot of questions.

please read the code what i developed

sample.vbs file -
Code:
EnvXMLfile = "C:\properties.xml"
libraryfile = "C:\\commonLibraryFunctions.vbs"
Set qtp_App = CreateObject("QuickTest.Application")
qtp_App.launch
qtp_App.Visible = True

qtp_App.Open "C:\sampletest",true,false
qtp_App.Test.Environment.LoadFromFile(EnvXMLfile)

qtp_App.Test.Settings.Resources.Libraries.RemoveAll
qtp_App.Test.Settings.Resources.Libraries.Add(libraryfile)
qtp_App.Test.Actions(1).ObjectRepositories.RemoveAll
qtp_App.Test.Actions(1).ObjectRepositories.Add "C:\Shared OR.tsr"
qtp_App.Test.Run


Now my questions are :

1. even though loading environmental file dynamically it will not show value in the QTP script, not able getting any values for environment veriable , but it is added dynamically ?

2.here i add .tsr file for one action , but a test can have multiple action , how could I associate that .tsr file for all the action with in the same test ?

3. even test can have some external action which is belongs to some different test and that test can have others .tsr file.
How could I handle it ?

Please answer my all above question and since I am new, I am trying to develope this piece of code.


Thanks in advance .....


RE: QTP AOM related Question - need solution - Jay - 05-02-2011

I am not sure about your first question. Find the rest of the answers
2:
To associate OR to multiple actions you have to write for each action
Like:
Code:
qtp_App.Test.Actions(1).ObjectRepositories.Add "C:\Shared OR.tsr"
qtp_App.Test.Actions(2).ObjectRepositories.Add "C:\Shared OR.tsr"

Here you can also write action name in the bracket instead of action index.

3.
if you use external action then there is no way you can use associate OR for that external action.
You have to use the OR which are already associated with external action.


RE: QTP AOM related Question - need solution - prodipto_dutta - 05-03-2011

Thanks for your answer.But I have question regarding your 2nd point.
qtp_App.Test.Actions(1).ObjectRepositories.Add "C:\Shared OR.tsr"
qtp_App.Test.Actions(2).ObjectRepositories.Add "C:\Shared OR.tsr"
I dont want to do that way because I called the startup.vbs file where
.tsr file will will be added and diff test can have diff number of action
so I want to make it duynamically ..
Is there any way to find out how many action have within a single test
so that when I run the vbs file from outside for a perticular test , its automatically associate .tsr file to all the actions for called test.

and regarding you 1st point I wanted to say ,
I associate a environmental file (.xml) into running test but in script when i want to see the environment value by suing msgbox like
val = environment("anyveriable")
msgbox val
I dont get any value but I added dynamically environmental file and it is showing in test setting also.
Am I doing anything wrong ?
Please put some light these 2 points what I said.

Thanks in advance ......


RE: QTP AOM related Question - need solution - Jay - 05-03-2011

You can use For i = 1 to qtp_app.Test.Actions.Count to get number of actions in script.

Regarding your second point you should be able to use xml environment file. As there is no error coming i will not be able to give you answer unless you send me your vbs file.

you can try with .ini text file to environment variable.



RE: QTP AOM related Question - need solution - prodipto_dutta - 05-03-2011

Thanks for your reply . point no 2 what you said its perfectly working.
in case of point no 3, Please find the sample script below:
Code:
[b]EnvXMLfile = "C:\ncs-stream-test\istarncsqtp\tests\common\properties.xml"[/b]
libraryfile = "C:\istar-gv-MUN\istar-gv\munqtp\tests\lib\commonLibraryFunctions.vbs"
Set qtp_App = CreateObject("QuickTest.Application")
qtp_App.launch
qtp_App.Visible = True
'Object.Open TestPath,OpenInReadOnlyMode,SaveCurrent
qtp_App.Open "C:\sampletest",false,false
[b]qtp_App.Test.Environment.LoadFromFile(EnvXMLfile)[/b]

qtp_App.Test.Settings.Resources.Libraries.RemoveAll
qtp_App.Test.Settings.Resources.Libraries.Add(libraryfile)
' find out number of actions in a perticular test
For i=1 To qtp_App.Test.Actions.Count
  qtp_App.Test.Actions(i).ObjectRepositories.RemoveAll
  qtp_App.Test.Actions(i).ObjectRepositories.Add "C:\Shared OR.tsr"
Next
qtp_App.Test.Run


Now I added environment xml file dynamically.
Just to check whether its added or not I put one msgbox inside qtp script
like :
Code:
[b]val = Environment.Value("xenosUrl")
msgbox val[/b]
browser("ISTAR GV").Page("ISTAR GV").WebEdit("j_username").Set "istar"
browser("ISTAR GV").Page("ISTAR GV").WebEdit("j_password").Set "istar"
browser("ISTAR GV").Page("ISTAR GV").Link("Login").Click



Now I didnt get any value for this msgbox but not getting any error also.
I dont know why ...
But if i added through test setting then i got the value.
for your understanding also attached one doc file that provides a snapshot that msg box does not display actual value.
I will try .ini what you have said earlier but I just wanted know why this is not working ?

Thanks for your effort and help.


RE: QTP AOM related Question - need solution - Jay - 05-03-2011

first see whether value for the variable xenosUrl is available. you can even try with some other variable from the xml as script code looks fine.


RE: QTP AOM related Question - need solution - prodipto_dutta - 05-04-2011

Thanks again.
Yes I checked, If i added environment xml through test setting before starting start.vbs file, I meant to say I added static way .not using dynamically throuigh .vbs file.It will show the value.
But while adding through .vbs file It will not showing the value.

Thanks in advance