我正在尝试使用VBA登录到网页,但无法完成它。问题出在打了用户名和密码之后,单击登录按钮时,网页显示错误为“必填字段”,因此基本上没有输入凭据。
我也尝试使用IE.document.getElementById(“ email”)。setAttribute(“ Value”)=“ XX”将值设置为属性,但仍然会抛出相同的错误。我也尝试过.focus方法,但是没有运气。
我希望我已经解释了我的问题,请为任何错误辩解。 网页链接“” https://dashboard.stripe.com/login”“我不能共享凭据,因为它是机密的。”
Set IE = CreateObject("InternetExplorer.application")
IE.Visible = True
IE.navigate "https://dashboard.stripe.com/login"
Do Until Not IE.busy: DoEvents: Loop
Set doc = IE.document
Do While doc.ReadyState <> "complete": DoEvents: Loop
IE.document.getelementbyid("email").Value = "a@A.com"
IE.document.getelementbyid("password").Value = "a"
Set ElementCol = IE.document.getElementsByTagName("span")
For Each link In ElementCol
If link.innerHTML = "Sign in to your account" Then
link.Click
End If
Next
答案 0 :(得分:1)
我对selenium basic执行了以下操作。安装后,转到VBE>工具>参考>添加对硒类型库的参考。
Option Explicit
Public Sub EnterInfo()
Dim d As WebDriver, keys As New Selenium.keys
Set d = New ChromeDriver
Const url = "https://dashboard.stripe.com/login"
With d
.AddArgument "--headless"
.Start "Chrome"
.get url
.FindElementById("email").SendKeys "joe.blogs@aol.com"
.FindElementById("password").SendKeys keys.Enter
.FindElementById("password").SendKeys "password"
.FindElementById("password").SendKeys keys.Enter
.FindElementByTag("form").submit
Stop '<== Delete me
'.Quit
End With
End Sub