I've written some code in vba using IE to choose England Premier League
from a dropdown which is visible as Next To Play
at this moment. My target is to click on that dropdown link captioned as Next To Play
and then choose the Australia A-League
from option. However, I can't find any way to click on that very link. If I run my below script the way it is, it neither works nor throws any error and finally quits the browser.
Link to that webpage: URL
Here is what I've tried so far:
Sub soccer()
Dim IE As New InternetExplorer, html As HTMLDocument
Dim post As Object
With IE
.Visible = True
.navigate "replace_with_above_link"
Do Until .readyState = READYSTATE_COMPLETE: Loop
Set html = .document
End With
Application.Wait Now + TimeValue("00:00:05")
For Each post In html.getElementsByTagName("option")
'' If InStr(post.innerText, "Next To Play") > 0 Then MsgBox post.innerText: Exit For ''checked to see if I'm on the right place
If InStr(post.innerText, "Next To Play") > 0 Then post.Click: Exit For
Next post
IE.Quit
End Sub
This is the partial picture of the webpage where I wanna trigger a click.
I would like to be able to click on that link and choose any option from there.
It seems I'm close to the solution. My below script can select the portion I wanna perform a click:
Sub Soccer_Dropdown()
Dim IE As New InternetExplorer, html As HTMLDocument
Dim post As Object
With IE
.Visible = True
.navigate "https://ubet.com/sports/soccer/nexttoplay"
Do Until .readyState = 4: DoEvents: Loop
Set html = .document
End With
Application.Wait Now + TimeValue("00:00:05")
Set post = html.querySelector(".ubet-fixed-price-navigator-selector-league select")
post.Focus
' IE.Quit
End Sub
Picture of the result:
However, when it comes to perform a click I can't do anymore.