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?
we.FindElementByXPath("//evo-link-button[@type='secondary']").Click
This might work for you. It gives me the following error message -
Run-time error 11
ElementNotVisibleError
element not interactable
The error message suggests that the XPath is valid and has found the element that I am aiming for but will not click it until other conditions are met, for example a valid username has been entered which I don't have.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With