I have used VBA macros in Excel 2016 along with Chrome and Selenium WebDriver to log-in to many different websites, but I haven't been able to programmatically log into the AARP website with the following code.
' Open the "AARP" web page
WDriver.Start "chrome"
WDriver.Window.Maximize
WDriver.Get "https://www.medicare.uhc.com/AARP"
Application.Wait (Now + TimeValue("0:00:05"))
' Find the "Sign In" button and click it
Set Results = WDriver.FindElementsByTag("button")
For Each itm In Results
If InStr(1, itm.Text, "Sign In", vbTextCompare) > 0 Then
itm.Click
Exit For
Else
End If
Next itm
' Wait until the page is fully loaded
Application.Wait (Now + TimeValue("0:00:10"))
' Enter Email address and PW and then click the Login button
WDriver.FindElementById("EMAIL").SendKeys ("") ' focus
WDriver.FindElementById("EMAIL").SendKeys ("abcd")
Application.Wait (Now + TimeValue("0:00:02"))
WDriver.FindElementById("PASSWORD").SendKeys ("") ' focus
WDriver.FindElementById("PASSWORD").SendKeys ("1234")
Application.Wait (Now + TimeValue("0:00:02"))
WDriver.FindElementById("submitBtn").Click
' Do stuff
I can see that the EMAIL address and PASSWORD are correct and inserted in the proper textboxes, but when the submit button is clicked a little wheel spins for a fraction of a second, but the unchanged webpage remains showing my email and pw.
If I now manually type in my correct email and pw, the little wheel spins again for a second, but again, nothing happens - no error message, nothing. The page can no longer be interacted with. If I want to try something else I need to close the webpage and start from the beginning with a new instance of Chrome.
If I start from the beginning and manually insert my email and pw, the website logs me in just fine. If I manually enter an incorrect email and pw I get the following message,
"Error: The username and password combination entered does not match our records."
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 error message shown above
The source code for the EMAIL input box is
<input id="EMAIL" class="form-control ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required" type="text" name="EMAIL" ng-model="sm.userInput" placeholder="" required="required" ng-blur="isValidUserNameEmail()" aria-invalid="true" data-nlok-ref-guid="345cd641-a989-4cee-a891-7e7cb5e43669">
The source code for the PASSWORD input box is very similar.