How to get the count of the Google search Result of a page using DP? – User friendly Tech help

n

Using Descriptive programming (DP) to count number of results on Google search page?

n

Solution:- Here we will use “Static type of DP” (by provide the set of properties and values directly) to find the Search results count.

n

Dim sSearch : sSearch = "UFTHelp.com"
'Function call to fetch the Result count fnSearch(sSearch)
'*********************Function to count search result*************************
Public Function fnSearch(sInput)
Dim objGoogle,sResult,sCount
'Open the browser with Google.com
SystemUtil.Run "iexplore.exe", "http://www.google.com"
'Creating the object of google page
Set objGoogle = Browser("title:=Google").Page("title:=Google")
'Set value for searching and click on search
If objGoogle.WebEdit("name:=q","type:=text").Exist(4) Then
objGoogle.WebEdit("name:=q","type:=text").Set sInput
End If
' clicking on search
If objGoogle.WebButton("name:=Google Search","type:=submit").Exist(2) Then
objGoogle.WebButton("name:=Google Search","type:=submit").Click
End If
'Fetching the Results count displayed
If Browser("title:=Google").Page("title:=.*Google Search").WebElement("html id:=resultStats").Exist(2) Then
sResult= Browser("title:=Google").Page("title:=.*Google Search").WebElement("html id:=resultStats").GetROProperty("innertext") Msgbox sResult
End If
'Incase we want exact result we can split the result to fetch the exact valuesCount = split(sResult)msgbox sCount(1)
End Function

n

nUnderstanding GetRoProperty

Was this article helpful?
YesNo

Similar Posts