I am trying to use Selenium in my Excel VBA code to scrape a page that requires a login to access. I haven't even gotten to the scraping part because my code fails at the login window. The site I am trying to access is part of ESPN's fantasy sports.
Based on feedback from the first version of my question, I have modified my code to select the correct iframe and include a timed loop (per Automation of iTunes connect VBA), but it still isn't working. Here is what I have so far:
Sub TestLoginToESPN2()
Dim bot As New WebDriver
Dim URL As String
Dim t As Date
Dim ele As Object
Const WAIT_TIME_SECS As Long = 30
t = Timer
URL = "https://fantasy.espn.com/football/team?leagueId=228988&teamId=10"
With bot
.Start "Chrome"
.Get URL
Do
DoEvents
If Timer - t > WAIT_TIME_SECS Then Exit Do
On Error Resume Next
.SwitchToFrame "disneyid-iframe"
Set ele = .FindElementByCss("input.ng-valid-pattern")
On Error GoTo 0
Loop While ele Is Nothing
If ele Is Nothing Then Exit Sub
ele.SendKeys ("asfdasfd")
Do
DoEvents
If Timer - t > WAIT_TIME_SECS Then Exit Do
On Error Resume Next
.SwitchToFrame "disneyid-iframe"
Set ele = .FindElementByCss("input.ng-valid-parse")
On Error GoTo 0
Loop While ele Is Nothing
If ele Is Nothing Then Exit Sub
ele.SendKeys ("password123")
.FindElementByCss("button.btn").Click
End With
Application.Wait Now + TimeValue("00:00:20")
End Sub
Only the first 1 or 2 characters of the username are entered in the User Name box, the complete password is entered but also in the User Name box (instead of the Password box) and I don't know if the button click works because the password is blank.
Any pointers on how to fix my code? Thanks!