点击IE浏览器中的按钮使用VBScript的CRA网站 [英] Clicking buttons in IE with VBScript on CRA website
问题描述
我是很新的VBScript和我试图通过自动化的CRA网站的 http://www.cra-arc.gc.ca/esrvc-srvce/tx/bsnss/pdoc-eng.html 在Excel中。我一直在努力,现在没有运气这出了几天。我觉得我的问题很简单:我想点击我接受按钮,上面的网站页面底部
I’m very new to VBScript and I’m trying to automate some payroll calculations through the CRA website http://www.cra-arc.gc.ca/esrvc-srvce/tx/bsnss/pdoc-eng.html in excel. I’m been trying to figure this out for few days now with no luck. I think my problem is very simple: I’m trying to click on the "I accept button" at the bottom of the page of the website above.
在code我写低于但下面的行,我不知道如何实际点击按钮。我总是得到一个错误,在这里不管我试试。
The code I’ve written is below but for the following line I don’t know how to actually click the button. I always get an error here whatever I try.
objIE.Application.document.getElementById("??????").Click
下面的HTML code没有ID。我也尝试过各种其他像getElementByType,getElementByValue没有运气
The HTML code below has no ID. I’ve also tried various other things like getElementByType, getElementByValue with no luck
VBScript中
Sub test()
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Application.Visible = True
objIE.Application.navigate "http://www.cra-arc.gc.ca/esrvc-srvce/tx/bsnss/pdoc-eng.html"
Do While objIE.Application.Busy Or _
objIE.Application.readyState <> 4
DoEvents
Loop
objIE.Application.document.getElementById("??????").Click
Do While objIE.Application.Busy Or _
objIE.Application.readyState <> 4
DoEvents
Loop
End Sub
HTML code
HTML Code
<div class="alignCenter">
<input type="button" title="I accept - Begin the calculation" value="I accept" onclick="parent.location='https://apps.cra-arc.gc.ca/ebci/rhpd/startLanguage.do?lang=English'" />
<input type="button" title="I do not accept - Return to Payroll" value="I do not accept" onclick="parent.location='/tx/bsnss/tpcs/pyrll/menu-eng.html'" />
</div>
我想AP preciate某人的帮助。
I would appreciate someones help.
谢谢,
太
推荐答案
需要注意的是VB / VBA 的DoEvents
函数在VBScript中不可用。然而,在这里工作code。
Note that VB/VBA DoEvents
function not available in VBScript. However, here is working code.
Call test
Sub test()
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate "http://www.cra-arc.gc.ca/esrvc-srvce/tx/bsnss/pdoc-eng.html"
Do While .Busy Or .readyState <> 4
WScript.Sleep 50
Loop
Set oInputs = .Document.getElementsByTagName("input")
For Each elm In oInputs
If elm.Value = "I accept" Then
elm.Click
Exit For
End If
Next
Do While .Busy Or .readyState <> 4
WScript.Sleep 50
Loop
End With
End Sub
这篇关于点击IE浏览器中的按钮使用VBScript的CRA网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!