The issue is, I'm unable to access the HTML element through a syntax which I followed for the newer versions of IE.
Here is the code syntax which works fine in IE 10 & 11
Set objInputs = internalContent.getElementsByClassName("linkedlinks") Set objElement = objInputs(0) ' this is where I'm facing the error
I am trying to get the first element among the list of HTML DOM elements, but the script is throwing an error in IE 9 browsers alone. Note: I verified the length of the objInputs; it is more than one. As I said, it works fine in IE 10 and 11
I'm getting the "Unknown runtime error", when the execution comes to that line.
Hint: What I think could be the possible solution is, the syntax could be changed a little in order to be supported in IE 9.
I need a way to access the first element alone from the list of elements got through 'getElementsByClassName'.
I tried
Set objElement = objInputs.FirstIndex
which didn't work as well. So can anyone kindly help me fix this issue. I'm struck here for the past few weeks; I tried a lot already.
Thanks a lot in advance.
Comment : Actually the script is for the IE automation, so I have the script code in a (.vbs) file.
"getElementsByClassName" works fine; I confirmed it using "objInputs.length". I'm getting the correct values but while trying to access the first element, I'm getting the error (the one in the screenshot).
I tried using
Set objElement = objInputs.Item(0)
Set objElement = objInputs[0]
but it seems, these syntaxes are not allowed.
I desperately need the first element as an object so that I can raise a click event through that object.