mardi 6 décembre 2016

automating the navigation between pages of a website with VBA

I'm landing on a webpage that has a menu on the left looking like this

Client
    contact history list inquiry
    contact history list
Client Search
Client Service

when you click on an item (eg: client) the sub items appear. if you click on a sub item, it brings you to a new page.

I am trying to automate these 2 steps using VBA. but I'm having no luck. Here is the related html

Collapsed

<P tabIndex=0 class=inactiveMenuItem _submenuid="menuLevel10"  _ingeniummenuid="00100">Client</P>
<UL id=menuLevel10 class=hiddenMenu _ingeniummenuid="00100" _parentmenuid="menuLevel1"></UL></LI>

Expanded

<P tabIndex=0 class=inactiveMenuItem _submenuid="menuLevel10" _ingeniummenuid="00100">Client</P>
<UL id=menuLevel10 class=visibleMenu _ingeniummenuid="00100" _parentmenuid="menuLevel1" _populated="true">
<LI><A class=inactiveMenuItem href="#" _flowname="BF1325InqList">Contact History List Inquiry</A></LI>
<LI><A class=inactiveMenuItem href="#" _flowname="BF1324List">Contact History List</A></LI>

I tried something like this

Dim objIE As New InternetExplorerMedium
Dim objDoc As HTMLDocument
Dim objElement As IHTMLElement

'go to website
objIE.Navigate ("http://SOMESITE.COM") (not the real site)
objIE.Visible = True

'sleep half seconds until page is loaded
Do Until objIE.ReadyState = READYSTATE_COMPLETE
    Sleep (500)
Loop

'click on menu item
Set objDoc = objIE.Document
Set objElement = objDoc.getElementById("menuLevel10")
objElement.Click

which didn't work. I also tried to trigger the OnClick event with the FireEvent function but that did not work either. Any help is appreciated. My knowledge of HTML is very limited so please tell me if I should add more of the HTML source code or if pieces of information are missing.

EDIT: it's an intranet site if that changes anything

Aucun commentaire:

Enregistrer un commentaire