Log-in to Website

Viewed 298

I'm trying to create an Excel macro that will log me into this website. I've written macros to log me into to other websites, but this one is somehow different.

When I use the following code to programmatically insert the username and password and then programmatically click the "log-in" button, the webpage comes back with the message

Error: please provide a username and Error: Please provide a password

Sub LogIn()
' Open IE and navigate to the log-in page    
    Set ie = CreateObject("InternetExplorer.Application")

    With ie
        .Visible = True
        .navigate "https://www.prudential.com/login"

' Loop until the page is fully loaded
        Do Until Not ie.Busy And ie.ReadyState = 4
            DoEvents
        Loop
        Application.Wait (Now + TimeValue("0:00:10"))

' Enter the necessary information on the Login web page and click the submit button
        ie.document.getElementById("username").Value = "abcdef"
        ie.document.getElementById("password").Value = "12345678"
        ie.document.getElementsByClassName("btn btn-primary btn-login btn-sm-block analytics-login")(0).Click

' Loop until the page is fully loaded
        Do Until Not ie.Busy And ie.ReadyState = 4
             DoEvents
        Loop
    End With

' Do stuff

' Quit IE
    ie.Quit
End Sub

I can see that my code has inserted the username and password into the webpage boxes, but for some reason after successfully clicking the submit button, the username and password are not being detected.

What code will successfully insert the username and password so that it can be processed by the web page? You'll know that your code works when you get the following error message:

We are unable to verify your username and password. Please try again.

Thanks for your help!

4 Answers
Related