WebScraper
New Member
- Joined
- Aug 21, 2017
- Messages
- 4
Hello,
I'm trying to open a webpage and then change the selection in a dropdown. The page is made in Java so it's quite hard to find IDs and Tags. My code is:
Through debugging I've managed to sort out that the dropdown I would like to change is found using iFrm.document.getElementsByClassName("selected")(0). The reason for using (0) is that there are 5 other dropdowns with the classname "selected" on the page.
What I would like to do is to change the selection in the dropdown from All (73) to the 4th. option called 'Equity Stockholm (11). I expect the base to be 0 hence the index to number 3. When adding a watch to DropDown I can see that its value is 0 but my code doesn't work when I try to change it to 3 though I'm a bit unsure that this is the right way to change the dropdown.
Anyone who can point me in the right direction so I can change the dropdown selection?
Thanks in advance.
I'm trying to open a webpage and then change the selection in a dropdown. The page is made in Java so it's quite hard to find IDs and Tags. My code is:
Code:
Sub GetShares()
Dim IE As New InternetExplorer
Dim HtmlDoc As New MSHTML.HTMLDocument
Dim iFrm As HTMLIFrame
Dim DropDown As MSHTML.HTMLInputElement
With IE
.navigate "http://turing.ngm.se/MDWebFront/quotes.html"
.Visible = True
Do While .Busy Or .READYSTATE <> READYSTATE_COMPLETE
DoEvents
Loop
Application.Wait (Now + TimeValue("00:00:03"))
Set HtmlDoc = .document
End With
Set iFrm = HtmlDoc.getElementById("quotesDiv")
Set DropDown = iFrm.document.getElementsByClassName("selected")(0)
DropDown.Value = 3
End Sub
Through debugging I've managed to sort out that the dropdown I would like to change is found using iFrm.document.getElementsByClassName("selected")(0). The reason for using (0) is that there are 5 other dropdowns with the classname "selected" on the page.
What I would like to do is to change the selection in the dropdown from All (73) to the 4th. option called 'Equity Stockholm (11). I expect the base to be 0 hence the index to number 3. When adding a watch to DropDown I can see that its value is 0 but my code doesn't work when I try to change it to 3 though I'm a bit unsure that this is the right way to change the dropdown.
Anyone who can point me in the right direction so I can change the dropdown selection?
Thanks in advance.