Hello,
I want to tell about the capturing of dynamically changing text.
Let's we have a task - it is needed to get the quantity of found results for some google search query. Please, see screenshot task.jpg. I highlighted the text to be captured.
So. let's start! :) It's easy, believe me :)
1. Start script recording for site
www.google.com. See step1.jpg
2. Enter "any query". See step2.jpg
3. Press "Google Search" btn
4. Results are shown. OK. See step3.jpg
5. Stop script recording in QTP
6. In QTP editor: Set cursor to last resorded step (Browser("
Google").Page("
any query - Google Search").Sync) and see active screen (step4.jpg).
7. Select text we want to capture ("76,400,000" in our case), right-mouse click and select ("Insert Text Output"). See
step5.jpg
8. Set "Text Before" to "10 of about ". See step6.jpg
9. Set "Text After" to " for ". See step7.jpg
Note: I have changed default value of "Text After". Initial value was " for any query. (
0.05 seconds) Script ". Default value does not suit us, since query ("any query") and time ("0.05 seconds") can vary from search to search, so we cannot capture the text correctly every time.
10. Set output value to be saved to DataTable. See step8.jpg
11. Modify script - Add one line to show captured text:
MsgBox(DataTable.
Value("
Quantity"))
That's all !!!
Run our script now and enjoy! We have done it! Please, see
step9.jpg
To make sure we wrote correct script, I changed the query to "play chess". And new captured result is "3,940,000". See
step10.jpg
As I've said - it's easy!
Any questions/comments?
--
Dmitry Motevich