Micro Focus QTP (UFT) Forums
get all text showing on web page - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: get all text showing on web page (/Thread-get-all-text-showing-on-web-page)



get all text showing on web page - daniel_QTP - 09-16-2012

How can i get all text showing on web page (QTP 11)?
For example,
I want to get into array all the text that appears on the next web page:
http://m.facebook.com/.


I tried the following code without success...

Code:
set objpage = Browser("Facebook").Page("Facebook")

Set childobjdes = Description.Create()
childobjdes("micclass").value = "WebElement"
childobjdes("Visible").Value = true

set allobj = objpage.ChildObjects(childobjdes)



RE: get all text showing on web page - Ankesh - 09-17-2012

try this

Code:
strPageText=Browser().Page().Object.body.innertext

strPageText is a string which now holds the entire text of the page.

Do let me know if you need more help.

Regards,
Ankesh


RE: get all text showing on web page - daniel_QTP - 09-17-2012

Actually it works, but I get the texts I do not see on the screen.
for example,
<input type="hidden" autocomplete="off" name="_fb_noscript" value="true" />

How can I get only the text that I see on the screen? and how I can work with any string and string separately? I mean, I have the ability to reach all the text on the screen separately and not all the text as one group

Thank you very much!

I tried the following code:

Code:
strPageText=Browser("Facebook").Page("Facebook").Object.body.innertext
strPageText= Split(strPageText,chr(10))


I got an array which is filled with empty values

[attachment=1126][attachment=1125]


RE: get all text showing on web page - jesonvan - 09-25-2012

sample code:

Code:
Function GetPageAllStringA(obj)

'  to escape invisible object, very difficult
'    If lcase(obj.body.style.visibility) = "hidden" or lcase(obj.body.style.display) = "inline-block" Then
'        GetPageAllStringA = ""
'        Exit Function
'    End If

    Set objChildren = obj.childNodes

    If  objChildren.length = 0 Then
        GetPageAllStringA = obj.innerText
        Exit Function
    End If

    For i = 0 to objChildren.length - 1
        set obj = objChildren.item(i)
        GetPageAllStringA = GetPageAllStringA & vbcrlf & obj.innerText        
    Next


End Function

str = GetPageAllStringA(Browser("Google").Page("Google").Object)

msgbox str