我想访问网站“表单”标签内存在的按钮,如果我打印表单的内部文本,我可以获取整个页面,但我不知道如何访问表单内的元素。
尝试过的代码:
Dim workFrame As HTMLFormElement, test As HTMLFormElement
Dim HTMLDoc As HTMLDocument
Set workFrame = ie2.Document.forms("ViewReferral")
Debug.Print workFrame.innerText ' it will print the whole page
Debug.Print workFrame.elements("notsuccess").innerText ' this triggered an error
网页
<form name="ViewReferral" action="viewreferral.php" method="POST">
<input name="Id" id="Id" type="hidden" value="11111">
<input name="Message" id="Message" type="hidden" value="">
<div id="data-form" style="padding: 10px;">
<div style="padding: 10px; float: left;"><h1>View Referral (Id = 11111)</h1></div>
<div class="order">
<a class="ui-button ui-corner-all ui-widget"role="button" style="float: right; display: inline;" href="managedocuments.php">Back</a>
<a class="ui-button ui-corner-all ui-widget" role="button" style="float: right; display: inline;" href="vieworder.pdf.php?OrderId=111111" target="_blank">Print</a>
<a class="VoidOrder ui-button ui-corner-all ui-widget" role="button" style="float: right; display: inline;" href="#1111"> Void</a>
<a class="ui-button ui-corner-all ui-widget" role="button" style="float: right; display: inline;" href="markasprocessed.php?OrderId=11111">Mark as Processed</a>
在这里我想激活 href="vieworder.pdf.php?
我无法访问网络表单内的表格,请帮助我解决此问题。
谢谢。
正式化我的评论,你应该尝试使用getElementsByClassName
,它返回文档或表单中具有给定类的每个元素的数组。就你而言,自从<a>
您要使用的标签是该类的第二个标签"ui-button ui-corner-all ui-widget"
,并且位于workFrame
表单,应该适合您的代码行是:
workFrame.getElementsByClassName("ui-button ui-corner-all ui-widget") (1)
其中 (1) 告诉程序返回数组中的第二项(数组从 0 开始索引)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)