jeudi 4 mai 2017

Web Automation Drop Down List

I'm working on a project to make my job easier. I work for a solar company where I set up and program inverters for the first time before they come on line. The interface for these inverters is through a web browser. Doing a little research I discovered that you can automate web browser function with VBA, awesome. So I am able to get the IE browser to open and go to where I want it to go, but that's where my luck runs out.

Sub CommissioningAutomation()

Dim ie As InternetExplorer
Dim html As HTMLDocument

Set ie = New InternetExplorer

ie.Visible = True

ie.navigate "xxx.xxx.xxx.xxx"
Do
DoEvents
Loop Until ie.readyState = 4

Set html = ie.document

Set drp = html.getElementByID("userLevel")

drp.selectIndex = "3"

Set ie = Nothing

Application.StatusBar = ""

End Sub

The XXX.XXX.XXX.XXX is the ip address for the inverter. So the web page opens and navigates to where in needs to go, but the application always faults out after that. Run-time error '438": Object doesn't support this property or method. When I click debug it highlights this "Set drp = html.getElementByName(“userLevel”)". To log into the inverter you have to select you user level and enter the appropriate password. I right clicked on the user level drop down and selected inspect element and this is what I see (picture attached).enter image description here




Aucun commentaire:

Enregistrer un commentaire