Today I'm going to show:
How to use QTP DP to perform different operations on objects.
For example, how to type text in these edit boxes on Google Sets page:
From previous QTP DP tutorial you know that this code returns a collection of Edits located on Web page:
So, to type text in each Edit, we have to process edit boxes from returned collection one by one.
We can access the specified item from a collection by item's index.
For example, the following code types a text in the first edit box:
And its result is:
Note: ChildObjects returns zero-based collection of found objects.
That's why use Edits(0) to access first item, Edits(1) to access second item, and so on.
So, we add a loop to process all edit boxes on a page.
The final QTP script is:
This code fills all Edits in. So, the result page looks like:
As you can see - QuickTest Professional Descriptive Programming works correctly.
Note: If the initial page contains more (i.e. 8) or less (i.e. 3) number of edit boxes, our QTP script will work without changes!
Note: Since we do not use QTP Object Repository (QTP OR), this approach can be integrated easily into any existing QTP system. Shared Object Repository is not required!
The article shows how to perform operations on objects.
The approach uses QuickTest Professional Descriptive Programming.
- QTP VIDEO - How to run test from command line?
- QTP Descriptive Programming - How to get number of objects
- QTP Descriptive programming - Processing images
- QTP Descriptive Programming - How to close browsers
- QTP - How to get number of pages in PDF file?
- QTP - How to set/get system time and date?
- All QTP visual tutorials
Do you like this QTP tutorial? Would you like to receive them in the future?
If yes, please subscribe to this blog RSS feed or by Email. (How to subscribe? VIDEO guide)