9

Capturing Text Using QTP

Embed Size (px)

Citation preview

Page 1: Capturing Text Using QTP
Page 2: Capturing Text Using QTP
Page 3: Capturing Text Using QTP
Page 4: Capturing Text Using QTP
Page 5: Capturing Text Using QTP
Page 6: Capturing Text Using QTP
Page 7: Capturing Text Using QTP
Page 8: Capturing Text Using QTP

Steps

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

Page 9: Capturing Text Using QTP

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 !!!