无法使用VBA在网页中输入用户名和密码 [英] Unable to enter Username and password in webpage using VBA

查看:529
本文介绍了无法使用VBA在网页中输入用户名和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用VBA登录到网页,但无法完成它.问题出在打了用户名和密码之后,单击登录按钮时,网页显示错误为必填字段",因此基本上没有输入凭据.

I am trying to login to a webpage using VBA, but I am unable to get it done. The issue is after the username and password punched, when clicking the signin button the webpage gives an error as "Required field" so basically the credentials are not entered.

我也尝试使用IE.document.getElementById("email").setAttribute("Value")="XX"将值设置为属性,但仍然会抛出相同的错误.我也尝试过.focus方法,但是没有运气.

I have also tried to set the value to the attribute using IE.document.getElementById("email").setAttribute("Value") = "XX" but still is throws the same error. I have also tried .focus method too but no luck.

我希望我已经解释了我的问题,请为任何错误辩解. 网页链接" https://dashboard.stripe.com/login "我无法共享凭据,因为它是机密的."

I hope I have explained my issue, kindly excuse for any errors. The webpage link "" https://dashboard.stripe.com/login"" I cannot share the credentials as it is confidential."

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

推荐答案

我对基本硒进行了以下操作.安装后,转到VBE>工具>参考>添加对硒类型库的参考.

I did the following with selenium basic. After install go to VBE > Tools > References > Add reference to selenium type library.

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

这篇关于无法使用VBA在网页中输入用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆