使用VBA,如何单击下一页上的橙色“登录”按钮: https://www.solaraccreditation.com.au/login.html
检查元素显示:
<input class="button bg-orange" value="Login" type="submit">
到目前为止,我的代码是:
Option Explicit
Private Declare Sub ShowWindow Lib "user32" _
(ByVal hWnd As Long, ByVal nCmdShow As Long)
Const strTMP As String = "Excel VBA"
Private Const SW_MAXIMIZE = 3
Public Sub Test()
Dim objWindow As Object
Dim objIEApp As Object
Dim objShell As Object
Dim objItem As Object
Dim objInputs As Object
Dim ele As Object
On Error GoTo Fin
Set objShell = CreateObject("Shell.Application")
Set objWindow = objShell.Windows()
For Each objItem In objWindow
If LCase(objItem.FullName Like "*iexplore*") Then
Set objIEApp = objItem
End If
Next objItem
If objIEApp Is Nothing Then
Set objIEApp = CreateObject("InternetExplorer.Application")
objIEApp.Visible = True
End If
With objIEApp
.Visible = True
ShowWindow .hWnd, SW_MAXIMIZE
.Navigate "https://www.solaraccreditation.com.au/login.html"
While Not .ReadyState = 4
DoEvents
Wend
.document.All("username").Value = _
ThisWorkbook.Sheets("sheet1").Range("a1")
.document.All("password").Value = _
ThisWorkbook.Sheets("sheet1").Range("a2")
End With
' <input class="button bg-orange" type="submit" value="Login" />
Fin:
If Err.Number <> 0 Then MsgBox "Error: " & _
Err.Number & " " & Err.Description
Set objWindow = Nothing
Set objShell = Nothing
End Sub
Mary Poppins的“经典迪士尼”配乐。 ...嗯,骗子,骗子,嗯,骗子是x2吗?现在,您可以向后说,这是docious-ali-expi-listic-frag
i-cali-rupus。
答案 0 :(得分:1)
您可以尝试将按钮识别为同类按钮中的第一个按钮。
.document.getelementsbyclass("button bg-orange")(0).click
但是简单地强制提交表单可能更方便。
.document.getelementbyid("loginForm").submit