Click a button on a webpage using Selenium Excel VBA for chrome

I am trying to automate a process of downloading a form for multiple months from a government website. It requires me to log in to my account and then proceed with clicking some buttons. For some reason, I don't want to use IE automation, and so, I have chosen to use Selenium through Excel VBA to automate Chrome. I am able to login, however, I can't click on the buttons after login. My VBA Code till now is as follows -

Sub Download2A()

Dim obj As New WebDriver
obj.Start "Chrome", ""
obj.Get "https://services.gst.gov.in/services/login"

obj.FindElementById("username").SendKeys ("myloginID")
obj.FindElementById("user_pass").SendKeys ("myPassword")
obj.FindElementById("captcha").Click

Do Until InStr(1, obj.URL, "fowelcome") > 0
    Application.Wait (DateAdd("s", 1, Now))
    DoEvents
Loop

After This, I want to click on a button for which the HTML is

<button type="button" class="btn btn-primary pad-l-50 pad-r-50" onclick="location.href='//return.gst.gov.in/returns/auth/dashboard'"><span title="Return Dashboard">Return Dashboard</span> <i class="fa fa-angle-right"></i></button>

Please Note, there are other Buttons with the same class. Please guide on how do I click this button?


Solution 1:

Use the following xpath to click.

XPATH1:

obj.FindElementByXPath("//button[.//span[@title='Return Dashboard']]").Click

XPATH2:

obj.FindElementByXPath("//button[.//span[text()='Return Dashboard']]").Click

Please note: Provide some wait before interacting the elements.