我正在尝试使用 VBA 访问我的 webtext a/c。 第一步是尝试获取用户名和密码输入框的标签。
我使用检查元素来确定标签,我认为它们是 “用户名和密码”。然而,这是行不通的。不幸的是,我没有 CSS 经验。
这是我的代码。
Sub MyLogin()
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.Navigate "http://www.o2online.ie/o2/login/"
Do Until .ReadyState = 4
DoEvents
Loop
.document.all.Item("username").Value = "MyUsername"
.document.all.Item("password").Value = "MyPassword"
.document.forms(1).submit
End With
End Sub
感谢任何帮助。
问候,遗憾
最佳答案
由于登录表单位于 iframe 内部,因此可能不允许直接访问该控件。
尝试下面的代码
Sub MyLogin()
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.Navigate "https://www.o2online.ie/idm/login/lightBoxLogin.jsp?authn_try_count=0&contextType=external&username"
Do Until .ReadyState = 4
DoEvents
Loop
.document.all.Item("username").Value = "MyUsername"
.document.all.Item("password").Value = "MyPassword"
.document.forms(0).submit
.Navigate "http://www.o2online.ie/o2/login/"
End With
End Sub
关于html - 使用 VBA 进行 Web 登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20470634/