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.
Code tried:
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
Web Page
<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>
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.
Formalizing my comment, what you should try is using
getElementsByClassName
, which returns an array of every element in the document or form with a given class. In your case, since the<a>
tag you want to work with is the second tag with the class"ui-button ui-corner-all ui-widget"
, and is in theworkFrame
form, the code line that should work for you is:where the (1) tells the program to return the second item in the array (arrays start indexing from 0).
A nice CSS selector was given in the comments with
The
*
means containing. So thea
tag that has anhref
containing the literal string'markasprocessed.php
Or
The
^
means starts with. So thea
tag that has anhref
starting with the literal string'markasprocessed.php
You could also use a less robust positional based selector with:
The 4th
a
tag containing anhref.