Dim O1
Set O1 = Description.Create
O1= "Any Property goes here"
Call Fun1(O1)
Function Fun1(ByRef O1)
msgbox O1
End Function
Tuesday, 14 October 2008
Monday, 6 October 2008
Implementing the datadriven framework
RowCount1 = Datatable.GetSheet("CRM_Supplier").GetRowcount
For j=0 to RowCount1-1
Datatable.SetCurrentRow(j+1)
For j=0 to RowCount1-1
Datatable.SetCurrentRow(j+1)
Monday, 29 September 2008
System Date change through QTP
Many a times an automation engineer can come up with a scnerio where he needs to change the system date. So how to approach this? Following is the code snippet that i have used and it works sucessfully:
sNewDate = Date + 5
sNewDate = Cdate(sNewDate)
Dim oShell
Set oShell = CreateObject ("WSCript.shell")
oShell.run "cmd /k Date " & sNewDate & "& Exit"
sNewDate = Date + 5
sNewDate = Cdate(sNewDate)
Dim oShell
Set oShell = CreateObject ("WSCript.shell")
oShell.run "cmd /k Date " & sNewDate & "& Exit"
Sunday, 21 September 2008
Why to go for SetTOProperty in QTP.
The SetToProperty can be useful when the engineer does not want to add the multiple objects of same type with differing values. The same can be explained with an example like we have two editboxes in the application and both differ by an assistive proprty.Here we can add only one of them in ObjectRepository and while dealing with the second one we can use the first Object and define the assistive property at runtime in code. The code can go as
Object(Description).SetTOProperty Property,Value
Lets explore the same with Flight application example:
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Type "shantanu"
Dialog("Login").WinEdit("Agent Name:").SetTOProperty "attached text","Password:"
Dialog("Login").WinEdit("Agent Name:").SetSecure "4884a1b87838d0a7a817a550056f14667e65eecd"
Dialog("Login").WinButton("OK").Click
Now here my ObjectRepository(OR) does contain only one WinEdit box and that is "Agent Name" only. So what i have done here is reduced the load on OR by defining the only one editbox and adding the second edit box at run time.
Object(Description).SetTOProperty Property,Value
Lets explore the same with Flight application example:
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Type "shantanu"
Dialog("Login").WinEdit("Agent Name:").SetTOProperty "attached text","Password:"
Dialog("Login").WinEdit("Agent Name:").SetSecure "4884a1b87838d0a7a817a550056f14667e65eecd"
Dialog("Login").WinButton("OK").Click
Now here my ObjectRepository(OR) does contain only one WinEdit box and that is "Agent Name" only. So what i have done here is reduced the load on OR by defining the only one editbox and adding the second edit box at run time.
Tuesday, 15 July 2008
DescriptiveProgramming and QTP
Why do we go for Descriptive Programming?
Many a times this question is posted on the various QTP Forums. Taking a practical example from my project i will try to illustrate why we go for Descriptive Programming.
My Project uses data driven Automation framework where we use the shared object repositories as well. The repositories are created after which there is always some addition of Objets on the same screens from AUT. So next time when i go for scripting the same screen i need to identify the newly added objects but i can not change the Object repositories as well as modifying the same will require me to change the name of the it and can hamper the smooth execution of previously crated scripts.
And so here comes into picture a handy feature of the QTP called DP(Descriptive Programming). So what i do exactly?
Through Object spy , I identify the mandatory properties of these Objects and write a code which looks like:
dim EdPartCombo 'Declare the Variable
Set EdPartCombo = Description.Create 'After this line we are setting up the mandatory properties to the above created Variable
EdPartCombo("window id").value = "1001"
EdPartCombo("nativeclass").value="Edit"
EdPartCombo("location").value="0"
and i put this code just before using the "EdPartCombo" in my script for the first time. So while executing the script when
QTP finds the above code it creats the Object and assigns the described properties to the same and uses this object in the script execution.
Many a times this question is posted on the various QTP Forums. Taking a practical example from my project i will try to illustrate why we go for Descriptive Programming.
My Project uses data driven Automation framework where we use the shared object repositories as well. The repositories are created after which there is always some addition of Objets on the same screens from AUT. So next time when i go for scripting the same screen i need to identify the newly added objects but i can not change the Object repositories as well as modifying the same will require me to change the name of the it and can hamper the smooth execution of previously crated scripts.
And so here comes into picture a handy feature of the QTP called DP(Descriptive Programming). So what i do exactly?
Through Object spy , I identify the mandatory properties of these Objects and write a code which looks like:
dim EdPartCombo 'Declare the Variable
Set EdPartCombo = Description.Create 'After this line we are setting up the mandatory properties to the above created Variable
EdPartCombo("window id").value = "1001"
EdPartCombo("nativeclass").value="Edit"
EdPartCombo("location").value="0"
and i put this code just before using the "EdPartCombo" in my script for the first time. So while executing the script when
QTP finds the above code it creats the Object and assigns the described properties to the same and uses this object in the script execution.
Subscribe to:
Comments (Atom)