Forum Discussion
HKosova
12 years agoSmartBear Alumni (Retired)
Hi Yvelise,
The contentDocument property is only available for Internet Explorer web pages starting from TestComplete 9. In earlier TestComplete versions, you need to use the Application.Document property to access the DOM document object.
Moreover, Internet Explorer doesn't natively support the textContent property prior to version 9, so you should use innerText instead. However, please be aware of a few differences between innerText and textContent.
You'll need to check the current browser and use the appropriate properties, like this:
The contentDocument property is only available for Internet Explorer web pages starting from TestComplete 9. In earlier TestComplete versions, you need to use the Application.Document property to access the DOM document object.
Moreover, Internet Explorer doesn't natively support the textContent property prior to version 9, so you should use innerText instead. However, please be aware of a few differences between innerText and textContent.
You'll need to check the current browser and use the appropriate properties, like this:
Sub Test
Dim url, browser, page, body, str
url = "http://www.google.fr"
strBrowser = "iexplore"
Set browser = Sys.Process(strBrowser)
Set page = browser.ToURL(url)
If LCase(browser.ProcessName) = "iexplore" Then
Set body = page.Application.Document.body
str = body.innerText
Else ' Firefox & Chrome
Set body = page.contentDocument.body
str = body.textContent
End If
Log.Message "See Additional Info.", str
End Sub