如何在< form>中获取元素网页标签? [英] how to get elements inside <form> tag of web page?

查看:65
本文介绍了如何在< form>中获取元素网页标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想访问网站的表单"标签中存在的按钮,如果我打印表单的内部文本,则可以获取整个页面,但我不知道如何访问其中的元素表格.

I would like to access a button which is present inside "form" tag of website, if i print the inner text of form i can able to get the entire page but i don't know how to access the elements inside the form.

尝试的代码:

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?
我无法访问网络表单中的表格,请帮助我解决此问题.
谢谢.

Here i would like to activate href="vieworder.pdf.php?
I am unable to access the tables inside the web form, please help me to fix this issue.
Thank You.

推荐答案

在带有

.Document.querySelector("a[href*='markasprocessed.php']")

*表示包含.因此,a标记的href包含文字字符串'markasprocessed.php

The * means containing. So the a tag that has an href containing the literal string 'markasprocessed.php

.Document.querySelector("a[href^='markasprocessed.php']")

^表示以开头.因此,具有href且以文字字符串'markasprocessed.php

The ^ means starts with. So the a tag that has an href starting with the literal string 'markasprocessed.php

您还可以将健壮的基于位置的选择器用于:

You could also use a less robust positional based selector with:

.Document.querySelector("a[href]:nth-child(4)")

第四个a标记,其中包含href.

The 4th a tag containing an href.

这篇关于如何在&lt; form&gt;中获取元素网页标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆