gpt4 book ai didi

javascript - 内网网页第二个按钮点击失败

转载 作者:行者123 更新时间:2023-11-28 06:54:02 25 4
gpt4 key购买 nike

enter image description here

除了typevalueonclick之外,第二个按钮元素中没有id元素;

下面是我的 webUI 代码

<input type="button" value="Download" 
onclick="javascript:__doPostBack('GridView1','Account_number$0')">

下面是我的 VBA 代码

Dim htmlDoc As HTMLDocument  
Dim MyBrowser As InternetExplorer
Dim MyHTML_Element As IHTMLElement
Dim myURL As String

On Error GoTo Err_Clear
myURL = "url......................."
Set MyBrowser = New InternetExplorer
MyBrowser.Silent = True
MyBrowser.Navigate myURL
MyBrowser.Visible = True
Do
Loop Until MyBrowser.ReadyState = READYSTATE_COMPLETE
Set htmlDoc = MyBrowser.Document

htmlDoc.all.txtAccNo.Value = "0" & "" & TextBox2.Value
htmlDoc.all.ddlReasons.Value = "1"
htmlDoc.all.txtRequester.Value = TextBox3.Text 'Enter your password here
htmlDoc.all.txtMobNo.Value = "0" & "" & TextBox1.Value
htmlDoc.all.txtLandLine.Value = ""
htmlDoc.all.txtEmailAdd.Value = Range("E15")
htmlDoc.all.ddlRelation.Value = "3"
htmlDoc.all.button1.Click

第二个按钮的打击脚本错误

htmlDoc.getElementsByXpath("input[type=""button""]").Click

请帮我,如何自动化这个按钮?

最佳答案

当我遇到这个问题时,我尝试为有问题的榆树找到一个独特的属性。原因是页面上可能还有其他您不想单击的按钮。看起来 onclickvalue 对于“下载”按钮是唯一的。我选择了。这是一个应该可以工作的单独函数(为了清楚起见)。它应该单击找到的第一个下载按钮。您可以通过修改函数将其设置为单击特定行的按钮。

Function ClickDownload(doc As IHTMLDocument) As Long
On Error GoTo ErrHandler
Dim elms As IHTMLElementCollection
Dim elm As IHTMLElement

Set elms = doc.getElementsByTagName("input") 'gather all input elms
For Each elm In elms 'book through each input elm until we find a match
If elm.Value = "Download" Then 'the elm.value "Download" seems unique enough
elm.Click
GoTo ErrHandler 'jump out, and be sure to set vars to nothing
End If
Next

ErrHandler:
Set elm = Nothing
Set elms = Nothing
ClickDownload = err.Number 'silently return 0 if it did not fail
End Function

关于javascript - 内网网页第二个按钮点击失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32716308/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com