0

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?

1 Answer 1

2

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.

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.