0
Sub login()

    Const Url$ = "https://commercial.metrobankonline.co.uk/portalserver/business-login"

    Dim UserName As String, Password As String, Scode As String, LoginData As Worksheet
    'Set LoginData = ThisWorkb ook.Worksheets("Sheet1")
    UserName = "123456789" 
    Password = "pwd" 

    Dim ie As Object
    Set ie = CreateObject("InternetExplorer.Application")
    Dim Btn As Object

    With ie

        .navigate Url
        ieBusy ie
        .Visible = True

        Dim oLogin As Object, oPassword As Object
        Dim ele As Object
        Set oLogin = .document.getElementsByName("customerNo")(0)


        oLogin.Value = UserName


  End With   
For Each ele In ie.document.getelementsbytagname("a")
    If InStr(ele.innertext, "Continue") > 0 Then ele.Click
Next
ie.Quit
End Sub

I am struggling to move to the next step of sign-in process by clicking the "Continue" button. below codes naviges to the web page sucessufly and puts the user name but fails to click the button.

1
  • Does the website have an API? If so, you should probably be using that instead of trying to automate the front-end, which is likely against the terms of use of the site you're requesting, and will start being impossible as soon as they add a recapcha mechanism to block "bots". Commented Apr 24, 2020 at 17:49

1 Answer 1

1

The code for that button is:

<button type="submit" class="btn btn-primary btn-block" ng-disabled="" ng-click="validate()">
    Continue
</button>

So you want to search for button tags not the anchor a tag:

For Each ele In ie.document.getelementsbytagname("button")

Alternatively (I've never tried this myself) but since the button is calling javascript function validate() you may be able to do a single line instead of a for loop:

ie.Document.parentWindow.execScript "validate();"
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much, looking for a "button" worked.

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.