Jump to content

Getting the elements of the element returns 'Variable must be of type "Object".'


Recommended Posts

Why this kind of code below, getting the tag name's element of the ID's element:
#include <IE.au3>
$oIE = _IECreate("http://www.example.com/", 0, 1, 1)
Sleep(5000)

$element = $oIE.document.getElementById("element_id")
$tags = $element.getElementsByTagName("IFRAME")

For $tag In $tags
   $msg = $tag.contentWindow.document.body
   MsgBox(0, "Message", $msg.innerHTML)
Next
And also this code, getting the class name's element of the ID's element:
#include <IE.au3>
$oIE = _IECreate("http://www.example.com/", 0, 1, 1)
Sleep(5000)

$element = $oIE.document.getElementById("element_id")
$classes = $element.getElementsByClassName("class_name")

For $class In $classes
   $msg = $class
   MsgBox(0, "Message", $msg.innerHTML)
Next

Returns the error 'Variable must be of type "Object".':

Variable must be of type "Object".:
MsgBox(0, "Message", $msg.innerHTML)
MsgBox(0, "Message", $msg^ ERROR

Instead of the inner HTML sources of the tag name's elements and the class name's elements?

What is the right way to do those?

Edited by Servant
Link to comment
Share on other sites

Try this:

#include <IE.au3>
$oIE = _IECreate("http://www.example.com/", 0, 1, 1)
Sleep(5000)

Local $tags = _IETagNameGetCollection($oIE, "input")
$element = $oIE.document.getElementById("element_id")

For $tag In $tags
   $msg = $tag.contentWindow.document.body
   MsgBox(0, "Message", $msg.innerHTML)
Next
Edited by sammy1983
Link to comment
Share on other sites

  • 2 months later...

Hello,

I have the same error message about iframe. I tried to start with the following methods :

_IETagNameGetCollection($oIE, "iframe")

_IEFrameGetObjByName($oIE, "HostedIFrame")

but it's impossible to find the html code, so "innerHtml" method fails with this error message.

Has anyone found a solution for Wayfarer ?

Thanks in advance and sorry for my english.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...