【发布时间】:2015-08-09 18:58:11
【问题描述】:
我已经为此工作了几天。我正在尝试浏览一个网站。我的下一步是单击一个按钮。不幸的是,该 URL 取决于先前的选择,所以我不能只点击链接。
这是我尝试单击的按钮的 HTML:
<div class="buttons">
<a class="greybutton" href="/pro/workouts/wizard?clientId=58806">
<span>Create a New Workout</span>
</a>
</div>
目前,我登录一个网站,在搜索框中输入一个值,弹出新信息,我点击一个按钮。现在,在一个新页面上,我想单击另一个按钮,但无法弄清楚。
这是我的 VBA 代码:
Sub TestWebsite()
Set ie = CreateObject("InternetExplorer.application")
ie.Visible = True
ie.Navigate ("https://functionalmovement.com/login?return=%2F" & ActiveCell)
Do
If ie.readyState = 4 Then
ie.Visible = True
Exit Do
Else
DoEvents
End If
Loop
ie.Document.forms(0).all("Username").Value = Range("B3")
ie.Document.forms(0).all("Password").Value = Range("B4")
Do While ie.Busy
Loop
ie.Document.forms(0).submit
Do While ie.Busy
Loop
Application.Wait (Now + TimeValue("0:00:01"))
ie.Navigate ("http://functionalmovement.com/pro/clients" & ActiveCell)
Do
If ie.readyState = 4 Then
ie.Visible = True
Exit Do
Else
DoEvents
End If
Loop
ie.Document.forms(1).all("gvClients$DXFREditorcol1").Value = Range("B6")
ie.Document.forms(1).all("gvClients$DXFREditorcol1").Select
SendKeys String:="{enter}", Wait:=True
Application.Wait (Now + TimeValue("0:00:03"))
SendKeys String:="{tab}"
SendKeys String:="{tab}"
SendKeys String:="{tab}"
SendKeys String:="{tab}"
SendKeys String:="{tab}"
SendKeys String:="{enter}"
Application.Wait (Now + TimeValue("0:00:10"))
这是我希望代码单击按钮的位置。
【问题讨论】: