Micro Focus QTP (UFT) Forums
Automating website using DOM. - 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: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: Automating website using DOM. (/Thread-Automating-website-using-DOM)



Automating website using DOM. - SAMVLAD - 12-07-2009

Hi Ankur,

I tried recording google.com via QTP but QTP is not able to recognize the objects so i decided to move on to DOM. I tried one script but its not working. kindly suggest what could be the possible reason for the error.

Below is the code-

Code:
Dim IE
Dim PageObject
Dim Button
Dim ButtonObjects


Set IE=CreateObject("InternetExplorer.Application")
IE.Visible=True
IE.Navigate "http://google.com"
[color=#FF0000]Set PageObject=IE.Document[/color]

Set ButtonObjects=PageObject.getElementsByTagName("Input")

For each Button in ButtonObjects
if Button.name="btng" or Button.type="submit" then
    if Button.value="Google Search" then
    Button.Click
    end if
Exit For
End if
Next

In the Above set of codes, I am getting an error in
Set PageObject=IE.Document
as Unspecified error.

Kindly suggest. If you can provide more insight into DOM that would be great. I mean Why an object has to be changed to Document before it can be used for getElementsByNameTag property likewise what are the other DOM properties which we can use and on what all objects?