Tuesday, September 3, 2019
Monday, November 9, 2015
Learn QTP scripting in 5 Minutes...
Yes, you can start QTP scripting with in 5 minutes, how?
Suppose you want to automate Mercury Application, you will follow the steps:
1. Will launch the QTP and Application
2. Will open the OR to add objects
3. Will start writing script i.e.
Dialog("Login").WinEdit("Agent Name:").Set "mercury" 'Desktop App'
Browser("google).Page("google").WebEdit("abc").Set "Testing"
But what is Dialog/Browser/Page or WinEdit/WebEdit? and Where it comes from?
Dialog is an object of Dialog class and it has a property name "text" and value "Login".
To start writing script go to the root in Object Repository and select the root object (See Login).
Now see its Class under Object Properties that is "Dialog", you can also see "text" property and it's value "Login" in Description properties.
Type "Class(" in Expert View you will see the property comes automatically and close the bracket..
Dialog("Login")
Now select the next object in Object repository, see it's Class "WinEdit" under Object properties and property "attached text" with value "Agent Name:" in Description properties
Dialog(//"Login").WinEdit(..//"Agent Name:")
Now, you don't have any object left in Object Repository side, it indicates you have reached to the object on which you will apply the action.
Dialog(//"Login").WinEdit(..//"Agent Name:").Set "mercury"
Here, "Set" is a QTP method.
Now you have one step ready for Agent Name text box.
Similarly you can generate the step for Password textbox and Ok button.
Dialog(//"Login").WinEdit(..//"Password").Set "mercury"
Dialog(//"Login").WinButton(..//"OK").Click
Suppose you want to automate Mercury Application, you will follow the steps:
1. Will launch the QTP and Application
2. Will open the OR to add objects
3. Will start writing script i.e.
Dialog("Login").WinEdit("Agent Name:").Set "mercury" 'Desktop App'
Browser("google).Page("google").WebEdit("abc").Set "Testing"
But what is Dialog/Browser/Page or WinEdit/WebEdit? and Where it comes from?
Dialog is an object of Dialog class and it has a property name "text" and value "Login".
To start writing script go to the root in Object Repository and select the root object (See Login).
Now see its Class under Object Properties that is "Dialog", you can also see "text" property and it's value "Login" in Description properties.
Type "Class(" in Expert View you will see the property comes automatically and close the bracket..
Dialog("Login")
Now select the next object in Object repository, see it's Class "WinEdit" under Object properties and property "attached text" with value "Agent Name:" in Description properties
Dialog(//"Login").WinEdit(..//"Agent Name:")
Now, you don't have any object left in Object Repository side, it indicates you have reached to the object on which you will apply the action.
Dialog(//"Login").WinEdit(..//"Agent Name:").Set "mercury"
Here, "Set" is a QTP method.
Now you have one step ready for Agent Name text box.
Similarly you can generate the step for Password textbox and Ok button.
Dialog(//"Login").WinEdit(..//"Password").Set "mercury"
Dialog(//"Login").WinButton(..//"OK").Click
How QTP and TestComplete Works
Suppose, we are given an application to automate. Let's start
1. Launch QTP.
2. Open Object Repository to add object (Test Time Object Property). You will see 'Agent Name" selected(Left) is a object of a WinEdit class. You can also see the "attached text" test time object property name and it's value "Agent Name:".
3. Dialog('Login").WinEdit("Agent Name:").Set "mercury"
This line says 'Enter "mercury" in "Agent Name:" exists on "Login" Dialog (Screen).
At run time QTP will search for object of WinEdit class whose run time object property is "attached text" and value is "Agent Name:". If it finds successfully, result is 'Passed" else 'Failed".
1. Launch QTP.
2. Open Object Repository to add object (Test Time Object Property). You will see 'Agent Name" selected(Left) is a object of a WinEdit class. You can also see the "attached text" test time object property name and it's value "Agent Name:".
3. Dialog('Login").WinEdit("Agent Name:").Set "mercury"
This line says 'Enter "mercury" in "Agent Name:" exists on "Login" Dialog (Screen).
At run time QTP will search for object of WinEdit class whose run time object property is "attached text" and value is "Agent Name:". If it finds successfully, result is 'Passed" else 'Failed".
How test automation tools work
Although, It very much depends on the tool.
Let's take an example:- What will you do If you are asked to find a person living in a big city and some information of that person are given to you?
City Name: ABC
Street Name: Mall Road
Block: A
House Number: 289
Name of the person: Saad
You will say this is very easy, Yes it is very easy but how it works?
Step1: Will go to that city.
Step2: Will search the street.
Step3: Will search the Block A.
Step4: Will search 289 house number.
Step5: Will call Mr. ABC.
Done!, But how? let me explain:-
You were given some set of properties (Test time Properties). In Step1 you searched for City, how did you know that this is the city you were looking for?
Because, City name which you were given(Test time property) and the city you are in (Run time property) are same. In each step you do the same.
Automation Tool work in the same way.
Let's take an example:- What will you do If you are asked to find a person living in a big city and some information of that person are given to you?
City Name: ABC
Street Name: Mall Road
Block: A
House Number: 289
Name of the person: Saad
You will say this is very easy, Yes it is very easy but how it works?
Step1: Will go to that city.
Step2: Will search the street.
Step3: Will search the Block A.
Step4: Will search 289 house number.
Step5: Will call Mr. ABC.
Done!, But how? let me explain:-
You were given some set of properties (Test time Properties). In Step1 you searched for City, how did you know that this is the city you were looking for?
Because, City name which you were given(Test time property) and the city you are in (Run time property) are same. In each step you do the same.
Automation Tool work in the same way.
Friday, August 6, 2010
Checkproperty method in QTP
Checks whether the specified object property achieves the specified value within the specified timeout.
Syntax: object.CheckProperty (PropertyName, PropertyValue, [TimeOut])
Eg. 1. Check the status of page.
>Browser("micclass:=Browser prop").Page("micclass:=Page prop").Object.CheckProperty ("status","done",3000)
Eg. 2.Verify the text AutomationTest has been entered on the name textbox.
>Browser(“micclass:=Browser prop”).Page(“micclass:=Page prop”).WebEdit(“name of text box”).Set “AutomationTest”
sCheck=Browser(“micclass:=Browser prop”).Page(“micclass:=Page prop”).WebEdit(“textbox name”).CheckProperty “value”, “AutomationTest”
Syntax: object.CheckProperty (PropertyName, PropertyValue, [TimeOut])
Eg. 1. Check the status of page.
>Browser("micclass:=Browser prop").Page("micclass:=Page prop").Object.CheckProperty ("status","done",3000)
Eg. 2.Verify the text AutomationTest has been entered on the name textbox.
>Browser(“micclass:=Browser prop”).Page(“micclass:=Page prop”).WebEdit(“name of text box”).Set “AutomationTest”
sCheck=Browser(“micclass:=Browser prop”).Page(“micclass:=Page prop”).WebEdit(“textbox name”).CheckProperty “value”, “AutomationTest”
Subscribe to:
Posts (Atom)