Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

InternetExplorer.Application access element with no ID

Status
Not open for further replies.

woter324

Technical User
Jan 26, 2007
179
GB
Hi,

I'm trying to automate the opening and login of several of our monitoring system web pages. It was all going well until I had to do HP System Insight Manager (SIM) where there is no ID tag given for me to tell it to ".click()".

On other pages, I have done this:
Code:
Set oIE5LB = CreateObject("InternetExplorer.Application")
oIE5LB.Visible = True
oIE5LB.Navigate "[URL unfurl="true"]https://somedeviceurl/Appliance"[/URL]
oIE5LB.Width = 840
oIE5LB.Height = 1028
oIE5LB.Top = 0
oIE5LB.Left = 840
oIE5LB.AddressBar = False 
oIE5LB.ToolBar = False
WaitForLoad(oIE5LB)
oIE5LB.Document.all("overridelink").click() 'As there is a certificate error
oIE5LB.Document.forms("mswlogin").all("userid").Value="AnROUser"
oIE5LB.Document.forms("mswlogin").all("pass").Value="myPasswordInClearText"
oIE5LB.Document.forms("mswlogin").all("stdButton").click()
oIE5LB.Document.forms("mswLogin").submit()
WaitForLoad(oIE5LB)
oIE5LB.Document.all("mtbHealth").click()

Where mtbHealth is the ID for the link I wish to automate. The HTML on the specific page looks like:
Code:
<a id="mtbHealth" href="/Appliance/SystemsCenter/Health/index.jsp">

Now for HP SIM, the HTML code looks like:
Code:
<tr>
  <td align="center" class="header-status-counts">
    <span id="firstStatusCritical" name="firstStatusCritical">
      <a title="All Systems: Critical Uncleared Events; click for details." class="header-status-counts" href="javascript:createList(5,2,90194313226,"All Systems: Critical Uncleared Events")">
In the <a> element there is no ID tag for me to reference.

I have tried:
Code:
Set test = oIE5LT.Document.getElementById("firstStatusCritical")
test.click()
But it returns "Object Required" on test.click.

If anyone could suggest a way of getting the hyperlink to open from code, I'd be very grateful.


One other thing, if a page uses windows authentication forms (from a different domain) is there a way I can pass credentials to the login prompt?

Many thanks

W.
 
test.click() operates on the test span object not the anchor object. Try (untested):

Code:
set span = document.getElementById("firstStatusCritical")
set anchor = span.getElementsByTagName("a")
msgbox anchor[0].value

.getElementByTagName() returns a collection of objects with the specified element name. Seeing as how there is only 1 anchor element within the span, only one object is returned and indexed cardinally (start from zero).

-Geates


"I do not offer answers, only considerations."
- Geates's Disclaimer

 
Thanks for your help Geates.

Unfortuanatly, I'm still getting "Object Required" on the Set oAnchor(0)... line.

The code I have tried:
Code:
Set oSpan = oIE5LT.Document.getElementById("firstStatusCritical")
Set oAnchor = oSpan.getElementByTagName("a")
oAnchor(0).click()
MsgBox oAnchor(0).value

Thanks Again.

W.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top