I've written the following code to open a webpage in Chrome (note, you may have to click through a "Captcha" robot test page). I can successfully enter my username and password, but I am unable to click the yellow Log in button.
Sub Annuity_Value_Selenium()
' Note: added reference to Selenium Type Library
Dim WDriver As New WebDriver
' Open Chrome and navigate to login page
WDriver.Start "Chrome", ""
WDriver.Get "https://www.prudential.com/login/"
' Maximize the window
WDriver.Window.Maximize
Application.Wait (Now + TimeValue("0:00:02"))
WDriver.Get "https://www.prudential.com/login/"
Application.Wait (Now + TimeValue("0:00:02"))
' log-in
WDriver.FindElementById("user").SendKeys ("abcd")
WDriver.FindElementById("password").SendKeys ("efgh")
WDriver.FindElementById("loginLink").Click
'
Do stuff
'
End sub
I have tried the following additional approaches as well, but I am still unsuccessful in clicking the Log in button:
WDriver.FindElementByCss("a[class='btn evo-button ']").Click
and
WDriver.FindElementByXPath("//a[contains(text(), 'Log in')]").click
I know that the webpage is loaded and active because the macro correctly inserts the username and password.
Even without using a username or password, you'll know that you were successful in clicking the button if you get an error message back saying Error: Please provide a username
. How can I programmatically click the Log in button?