I'm using a VBA macro in Excel 2016 along with Chrome and Selenium WebDriver to log-in to a website. With VBA and IE I found a way to log in using the old SendKeys method
' Open the "AARP" web page
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.Navigate "https://www.medicare.uhc.com/AARP"
.Top = 0
.Left = 0
.Height = 1056
.Width = 1936
End With
' Loop until the page is fully loaded
Do Until IE.ReadyState = 4 And Not IE.Busy
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:04"))
' Click the "Sign In" button
IE.Document.getElementsByClassName("btn btn-primary btn-block")(0).Click
' Loop until the page is fully loaded
Do Until IE.ReadyState = 4 And Not IE.Busy
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:12"))
Set WSS = CreateObject("WScript.Shell")
my_PW = "123"
my_ID = "abc"
IE.Document.getElementById("EMAIL").Focus
Application.Wait (Now + TimeValue("0:00:02"))
WSS.SendKeys my_ID
Application.Wait (Now + TimeValue("0:00:02"))
IE.Document.getElementById("PASSWORD").Focus
Application.Wait (Now + TimeValue("0:00:02"))
WSS.SendKeys my_PW
Application.Wait (Now + TimeValue("0:00:02"))
IE.Document.getElementById("submitBtn").Click
Using more traditional code such as
IE.Document.getElementById("EMAIL").Value = "abc"
IE.Document.getElementById("PASSWORD").Value = "123"
failed. You need to physically interact with the textbox.
I'm trying to migrate the code to work with Chrome and Selenium WebDriver. When I use code such as
WDriver.FindElementById("EMAIL").SendKeys ("") ' focus
WDriver.FindElementById("EMAIL").SendKeys ("abc")
WDriver.FindElementById("PASSWORD").SendKeys ("") ' focus
WDriver.FindElementById("PASSWORD").SendKeys ("123")
it puts the text in the proper boxes, but when I click the "Submit" button the website doesn't log me in. I presume that the code fails because it is not physically interacting with the text boxes. How can I physically interact with the text boxes (like the old SendKeys method did with IE) using Selenium WebDriver in VBA?
Thanks for your help...Ron