0

I have some code that used to work fine, but for some reason it has stopped selecting the tab that says "your leagues". The code pulls live football scores into excel. The only bit I need help with is where I need to navigate from all games to your leagues (the code does not recognize the button and so is not clicking it). Any help will be appreciated. Thanks.

 'Define Variables
        url = "http://www.futbol24.com/Live/livenow/"


    'Open url
        ie.Visible = False
        ie.Navigate url
        frmbusy.lbstatus.AddItem "Navigating to Web Page"
        busywait

    'Navigate from ALL Games to Your Leagues
        Set tagname = ie.Document.getelementsbytagname("*")

        For z = 0 To tagname.Length - 1
           If tagname(z).ID = "f24com_i18n_btnChooseLeague_your" Then
                tagname(z).Click
                busywait
            End If
        Next
12
  • Please examine the source HTML of this page, and you will find that the ID f24com_btnChooseLeague_your does not exist. Commented Feb 20, 2016 at 19:08
  • Nor is there a tab which says "Your leagues" (at least not when I view it, perhaps it is different if you log in...) Sometimes websites change the way they are built, and you need to modify your code when that happens. Commented Feb 20, 2016 at 19:10
  • Apologies. I've updated the tag name: "f24com_i18n_btnChooseLeague_your" but it still does not click it. Thanks. Commented Feb 20, 2016 at 19:48
  • Click is clearly not an event that is doing anything for this control. You may want to look in to using the Selenium wrapper to automate IE/Firefox/Chrome, in my experience it's more reliable than trying to bluntly automate IE directly. Also, consider using ie.Document.getElementByID("f24com_i18n_btnChooseLeague_your") if your version of IE supports that method, then you won't need the z loop as that will directly handle the element. You may need to manipulate the parent element somehow but i can't really tell for sure. Commented Feb 21, 2016 at 0:11
  • Also, if you can upload screenshot to imgur.com and indicate where this control or its parent are located on the page, I can't really find it so that makes it difficult to troubleshoot. Commented Feb 21, 2016 at 0:14

1 Answer 1

1

You can use a querySelector to target

#f24com_btnChooseLeague_choose > a > span

This is the span tag within an a tag with element with id #f24com_btnChooseLeague_choose

You can shorten this simply to #f24com_btnChooseLeague_choose > a

Option Explicit
Public Sub ClickChooseLeagues()
    Dim ie As New InternetExplorer
    With ie
        .Visible = True
        .navigate "https://www.futbol24.com/Live/livenow/"

        While .Busy Or .readyState < 4: DoEvents: Wend
        .document.querySelector("#f24com_btnChooseLeague_choose > a").Click

        Stop
    End With
End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.