Hi,
1.Can anybody give a sample code of Descriptive programming in QTP?(Not Definitions).
2. How can you test a Dynamic moving objects using QTP? If Tested? What is the code for that?
Printable View
Hi,
1.Can anybody give a sample code of Descriptive programming in QTP?(Not Definitions).
2. How can you test a Dynamic moving objects using QTP? If Tested? What is the code for that?
If we do only Descriptive programming in QTP without recoding, will the objects be identified in Object Repository and will the test run execute?
No only descriptive programming in QTP will not identify the objects and the test will not run.
You can write a QTP script using descriptive programming without recording.
You can use object spy to specify the object's properties so that it can be identified.
Note that the object repository is empty in this case but the script runs fine.
For example, following is the code I wrote to check this out.
It just searches for some string on google.
This runs the first time without any recording:
===========
Dim GBrowser : Set GBrowser=Browser("name:=Google.*")
Dim GPage : Set GPage=GBrowser.Page("title:=Google.*")
URL="http://www.google.com"
SystemUtil.run "iexplore",URL
GPage.WebEdit("name:=q","type:=text","html tag:=INPUT").Set "qtp"
GPage.WebButton("name:=Google Search","index:=0","type:=submit","html tag:=INPUT").Click
=====================
Please let me know if I am wrong.
Thanks.
Nice discussion going around. Ahuja1234 you are not wrong. You are right in your statement.
require some more information
Hi Ahuja,
your script is really good
Regards,
SM Ganesh
ex: for descriptive programming is
window("text:=Flight Reservation").winedit("attached text:=Name").set "zyx"
Hey guys first of all be aware of onething, For Descriptive programming Object repository is not required ..There is nothing to do with Object Repository if we are doing scripting descriptively..
Like our friends said in the above posts, We can use n number of attributes for scripting descriptively
[QUOTE=thotaravikiran;20] 1.Can anybody give a sample code of Descriptive programming in QTP?(Not Definitions).
QUOTE]
EG...
[B]Browser("BrowserName").Page("PageName").WebEdit("name:=Login","index:=0").Set "John"[/B]
Here, [B]"name"[/B] is one general property and [B]"index"[/B] is the unique property
[QUOTE=thotaravikiran;20]
2. How can you test a Dynamic moving objects using QTP? If Tested? What is the code for that?[/QUOTE]
For this kind of scenario use Regular Expression
[QUOTE=bharathi_ark;384]If we do only Descriptive programming in QTP without recoding, will the objects be identified in Object Repository and will the test run execute?[/QUOTE]
YES, It will run
[QUOTE=ahuja1234;2442]
===========
Dim GBrowser : Set GBrowser=Browser("name:=Google.*")
Dim GPage : Set GPage=GBrowser.Page("title:=Google.*")
URL="http://www.google.com"
SystemUtil.run "iexplore",URL
GPage.WebEdit("name:=q","type:=text","html tag:=INPUT").Set "qtp"
GPage.WebButton("name:=Google Search","index:=0","type:=submit","html tag:=INPUT").Click
=====================
Please let me know if I am wrong.
Thanks.[/QUOTE]
Hi Ahuja
This is really is good piece of code
even we practice something like this
[QUOTE=debleena23;10567][QUOTE=thotaravikiran;20] 1.Can anybody give a sample code of Descriptive programming in QTP?(Not Definitions).
QUOTE]
EG...
[B]Browser("BrowserName").Page("PageName").WebEdit("name:=Login","index:=0").Set "John"[/B]
Here, [B]"name"[/B] is one general property and [B]"index"[/B] is the unique property
For this kind of scenario use Regular Expression
YES, It will run
Hi Ahuja
This is really is good piece of code
even we practice something like this[/QUOTE]
Hi ahuja,can we write descrptive program without using spy.?here u declared
dim,why?can u explain me pls?
I must say... this is a smart piece of code from Ahuja.
We use Object Spy to get the properties and their values to uniquely identify the objects in the application. If we know such properties and their unique values that can identify the required object without ambiguity, we need not use Object Spy.
Instead of using --Browser("name:=Google.*")-- in the code each time we want to refer to the browser, we can set it as an object by declaring a variable with Dim statement. Now, the variable can be used as a shortcut for all references to the browser window and the web page.
The above program can be written using "With" statement where we don't have to declare the variables using Dim.
***********
With Browser("name:=Google.*").Page("title:=Google.*")
URL="http://www.google.com"
SystemUtil.run "iexplore",URL
.WebEdit("name:=q","type:=text","html tag:=INPUT").Set "qtp"
.WebButton("name:=Google Search","index:=0","type:=submit","html tag:=INPUT").Click
End With
***********
Hey really good piece of code
Hi Ahuja,
Nice descusion is going on..
Since object repository is empty then how the QTP recognize the object? Please clear on this ...
Thanks
Dhananjay
Hi Dhananjay,
In descriptive programming OR will be empty but QTP will identify the objects based on the property and values you provide while writing the code.
QTP can identify objects from the mandatory properties first....If it fails with mandatory properties then it will check for assistive properties....If it fails for assistive also then it will check for Ordinal properties....and lastly If it fails with ordinal also then it will go for creation Time property(Applicable only for Web Based Applications)......
Let me know if this cleared your doubt or not?????