Objects in IE are not getting identified by VBA - excel

Iam trying to automate IE Browser using VBA. There are nearly 25 links in the browser page but when i use getElementsByTagName("a") function VBA is identifying only 2 links form the page. Iam using IE 8 and MS Office 2007 package.
Have any one faced the same issue earlier. Kindly help
<form name="form1" action="/insurance/gs/servlet/API.gs.pol.nb.action.NewBizAction" method=post>
<input type="hidden" name='operId' value="">
<input type="hidden" name="policyId" value = "309865">
<input type="hidden" name='isCustomer' value="1">
<input type="hidden" name='indDeletePartyId' value="">
<input type="hidden" name='orgDeletePartyId' value="">
<input type="hidden" name='deletePartyId' value="">
<input type="hidden" name='roleType' value="">
<input type="hidden" name='submissionCustId' value="0">
<input type="hidden" name='newPartyId' value="null">
<input value="API.gs.pol.nb.action.NewBizAction?operId=LoaderCustInfo&policyId=309865" type="hidden" name="fromUrl" >
<table cellpadding="1" cellspacing="1" class="table_frame">
<tr>
<td class="body">
<div class="main">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_data">
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0" class="table_heading1">
<tr>
<td class="table_heading1_tdleft table_heading1_tdpic"></td>
<td class="table_heading1_td">
<table border="0" cellspacing="0" cellpadding="0" class="table_heading1_1">
<tr>
<td class="arrow_td"><img src="/insurance/icp/ifoundation/html/foundation/ui31/images/common/arrow1.gif" /></td>
<td width="49%" nowrap="nowrap" class="font_heading1">
Customer List
</td>
<td width="49%" align="right" >
<a class="a2" href="#" onClick="javascript:if(cheBefSelCust()){loadIndiCust()}">Individual</a>
<a class="a2" href="#" onClick="javascript:if(cheBefSelCust()){loadOrganCust()}">Company</a>
</td>
</tr>
</table>
</td>
<td class="table_heading1_tdright table_heading1_tdpic"></td>
</tr>
</table>
In the above HTML Page I want to Select the Link Individual

Related

Selenium Python select and click multiple checkbox elements by input type

Trying to select and click multiple checkboxes on a page. they don't have a class, ID or names that match. All they have in common is their input type (checkbox). I'm able to select individual checkboxes using XPATH but its not practical as there's at least 100 checkboxes on the page.
Here's a section of the HTML. I've been testing this code on an off-line version of the site.
<body>
<tbody>
<tr>
<td class="borderBot"><b>Activity</b></td>
<td class="borderBot">
<table cellpadding="3" cellspacing="3" width="100%">
<tbody>
<tr>
<td width="33%">
<input type="checkbox" name="competency1Activity" value="1" />
Plan (ie Interpreted diag etc)
</td>
<td width="33%">
<input type="checkbox" name="competency1Activity" value="2" />
Carry Out (ie conducted work)
</td>
<td width="33%">
<input type="checkbox" name="competency1Activity" value="4" />
Complete (ie Compliance etc)
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="borderBot"><b>Supervision</b></td>
<td class="borderBot">
<table cellpadding="3" cellspacing="3" width="100%">
<tbody>
<tr>
<td width="33%">
<input
type="checkbox"
name="competency1Supervision"
value="1"
/>
Direct
</td>
<td width="33%">
<input
type="checkbox"
name="competency1Supervision"
value="2"
/>
General
</td>
<td width="33%">
<input
type="checkbox"
name="competency1Supervision"
value="4"
/>
Broad
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="borderBot"><b>Support</b></td>
<td class="borderBot">
<table cellpadding="3" cellspacing="3" width="100%">
<tbody>
<tr>
<td width="33%">
<input type="checkbox" name="competency1Support" value="1" />
Constant
</td>
<td width="33%">
<input type="checkbox" name="competency1Support" value="2" />
Intermittent
</td>
<td width="33%">
<input type="checkbox" name="competency1Support" value="4" />
Minimal
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="borderBot"><b>Materials</b></td>
<td class="borderBot">
<table cellpadding="3" cellspacing="3" width="100%">
<tbody>
<tr>
<td width="50%">
<input type="checkbox" name="competency1Extended" value="1" />
Insulation failure
</td>
<td width="50%">
<input type="checkbox" name="competency1Extended" value="2" />
Incorrect connections
</td>
</tr>
<tr>
<td width="50%">
<input type="checkbox" name="competency1Extended" value="4" />
Circuits-wiring; eg. open short
</td>
<td width="50%">
<input type="checkbox" name="competency1Extended" value="8" />
Unsafe condition
</td>
</tr>
<tr>
<td width="50%">
<input
type="checkbox"
name="competency1Extended"
value="16"
/>
Apparatus/component failure
</td>
<td width="50%">
<input
type="checkbox"
name="competency1Extended"
value="32"
/>
Related mechanical failure
</td>
</tr>
<tr>
<td width="50%">
<input
type="checkbox"
name="competency1Extended"
value="64"
/>
Read/interpret drawings/plans
</td>
<td width="50%">
<input
type="checkbox"
name="competency1Extended"
value="128"
/>
Other elec app and circuit faults
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<input
type="hidden"
id="competency1ExtendedCount"
name="competency1ExtendedCount"
value="8"
/>
</tbody>
</body>
Try 1 - this selects and clicks the first checkbox but none of the others
checkboxes = driver.find_element(By.CSS_SELECTOR, "input[type='checkbox']").click()
Try 2 - Thought this would work but I cant get the syntax right
checkboxes = driver.find_element(By.CSS_SELECTOR, "input[type='checkbox']")
for checkbox in checkboxes:
checkboxes.click()
time.sleep(.3)
Try 3 - able to select first checkbox (of 3) with this name
checkboxes = driver.find_element("name", "competency1Ativity").click()
find_element() will return only the first matching element, where as you need to identify all of them. So you need to use find_elements() method.
Solution
You can identify all the checkbox and store the elements within a list and then click on them one by one using either of the following locator strategies:
Using CSS_SELECTOR:
from selenium.webdriver.common.by import By
checkboxes = driver.find_elements(By.CSS_SELECTOR, "td input[type='checkbox']")
for checkbox in checkboxes:
checkbox.click()
Using XPATH:
from selenium.webdriver.common.by import By
checkboxes = driver.find_elements(By.XPATH, "//td//input[#type='checkbox']")
for checkbox in checkboxes:
checkbox.click()
Your option 2 was nearly correct, however it should have been find_elements() not find_element()
Since find_element() just returns an webelement where as find_elements() returns list of elements.
code:
checkboxes = driver.find_elements(By.CSS_SELECTOR, "input[type='checkbox']")
for checkbox in checkboxes:
checkbox.click()
time.sleep(0.5)

How to check a checkbox in a web page which has a dynamic values , Using Excel VBA?

I have seen tutorials it is very informative and very easy to understand.
I have doubt in clicking a check box in a website using EXCEL VBA
the check box values will be dynamic.It seems to be very challenging for me. If someone helps me to fix this i will feel awesome.
I have mentioned below the HTML elements for your reference.
Requirement is to select qualifer code (2015, 2018 & KD) and delete.
Sub Editing_APA_Qualifiers()
Dim IE As Object
Dim Doc As HTMLDocument
Set IE = CreateObject("InternetExplorer.Application")
Dim SHELL_OBJECT
SHELL_OBJECT = "WScript.Shell"
Set objShell = CreateObject(SHELL_OBJECT)
IE.Visible = True
'navigate URL
IE.navigate "URL"
Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
Set Doc = IE.document
' Set numrows = number of rows of data.
NumRows = Range("A1", Range("A1").End(xlDown)).Rows.Count
' Establish "For" loop to loop "numrows" number of times.
For intRow = 2 To NumRows
IE.Visible = True
Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
Doc.getElementById("txtTimeStudyNbr").Value = ThisWorkbook.Sheets("data").Range("A" & intRow).Value
Doc.getElementById("Search").Click
Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
Doc.getElementsByName("chkDel").Value = ThisWorkbook.Sheets("data").Range("B" & intRow).Value(0).Click
Doc.getElementsByName("chkDel").Value = ThisWorkbook.Sheets("data").Range("C" & intRow).Value(0).Click
Doc.getElementsByName("chkDel")(7).Click
Doc.getElementById("Delete").Click
objShell.SendKeys "{Enter}"
Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
Doc.getElementById("lstQualifierTypes").Value = ThisWorkbook.Sheets("data").Range("E1").Value
Doc.getElementById("Search").Click
Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
Doc.getElementById("lstQualifiers").Value = ThisWorkbook.Sheets("data").Range("E2").Value
Doc.getElementById("ADD").Click
Next
End Sub
So in these how we can select the check boxes.
For your easy reference
<input type="checkbox" name="chkDel" value="0|MY|2018~"></td>
<input type="checkbox" name="chkDel" value="1|MY|2017~"></td>
<input type="checkbox" name="chkDel" value="2|MY|2016~"></td>
<input type="checkbox" name="chkDel" value="3|MY|2015~"></td>
<input type="checkbox" name="chkDel" value="4|VT|L~"></td>
<input type="checkbox" name="chkDel" value="5|VL|KD~"></td>
<input type="checkbox" name="chkDel" value="6|VL|K#~"></td>
<tbody><tr style="background-color:#ada5bd">
<th> </th>
<th class="center">Del</th>
<th class="center">Qualifier Type</th>
<th class="center">Qualifier Code </th>
<th class="center">Abbreviation </th>
<th class="center">Print </th>
<th class="center">Rev </th>
<th class="center">User Id </th>
<th class="center">Date </th></tr>
<!-- Printing -->
<!-- QT="MY" QC="2018" -->
<!-- UpdateId:VKUMARAG -->
<input type="hidden" name="QualifierType0" value="MY">
<input type="hidden" name="QualifierCode0" value="2018">
<input type="hidden" name="Print0" value="Y">
<tr id="tr0"><td width="1"> <input type="radio" name="rdOperation" onclick="return radio_onclick(0)"> </td>
<td width="1">
<input type="checkbox" name="chkDel" value="0|MY|2018~"></td>
<td class="center">
MY</td>
<td class="center">
2018</td>
<td class="left">
Eff: Ineff: </td>
<td class="center">
Y</td>
<td class="center">
A</td>
<td class="left">
VKUMARAG</td>
<td class="left">
06-mar-2018</td>
</tr>
<!-- Printing -->
<!-- QT="MY" QC="2017" -->
<!-- UpdateId:VKUMARAG -->
<input type="hidden" name="QualifierType1" value="MY">
<input type="hidden" name="QualifierCode1" value="2017">
<input type="hidden" name="Print1" value="Y">
<tr id="tr1"><td width="1"> <input type="radio" name="rdOperation" onclick="return radio_onclick(1)"> </td>
<td width="1">
<input type="checkbox" name="chkDel" value="1|MY|2017~"></td>
<td class="center">
MY</td>
<td class="center">
2017</td>
<td class="left">
Eff: Ineff: </td>
<td class="center">
Y</td>
<td class="center">
A</td>
<td class="left">
VKUMARAG</td>
<td class="left">
27-may-2016</td>
</tr>
<!-- Printing -->
<!-- QT="MY" QC="2016" -->
<!-- UpdateId:ACYRUS3 -->
<input type="hidden" name="QualifierType2" value="MY">
<input type="hidden" name="QualifierCode2" value="2016">
<input type="hidden" name="Print2" value="Y">
<tr id="tr2"><td width="1"> <input type="radio" name="rdOperation" onclick="return radio_onclick(2)"> </td>
<td width="1">
<input type="checkbox" name="chkDel" value="2|MY|2016~"></td>
<td class="center">
MY</td>
<td class="center">
2016</td>
<td class="left">
Eff: Ineff: </td>
<td class="center">
Y</td>
<td class="center">
A</td>
<td class="left">
ACYRUS3</td>
<td class="left">
17-nov-2015</td>
</tr>
<!-- Printing -->
<!-- QT="MY" QC="2015" -->
<!-- UpdateId:APIMPORT -->
<input type="hidden" name="QualifierType3" value="MY">
<input type="hidden" name="QualifierCode3" value="2015">
<input type="hidden" name="Print3" value="Y">
<tr id="tr3"><td width="1"> <input type="radio" name="rdOperation" onclick="return radio_onclick(3)"> </td>
<td width="1">
<input type="checkbox" name="chkDel" value="3|MY|2015~"></td>
<td class="center">
MY</td>
<td class="center">
2015</td>
<td class="left">
Eff: Ineff: </td>
<td class="center">
Y</td>
<td class="center">
A</td>
<td class="left">
APIMPORT</td>
<td class="left">
20-sep-2013</td>
</tr>
<!-- Printing -->
<!-- QT="VT" QC="L" -->
<!-- UpdateId:APIMPORT -->
<input type="hidden" name="QualifierType4" value="VT">
<input type="hidden" name="QualifierCode4" value="L">
<input type="hidden" name="Print4" value="Y">
<tr id="tr4"><td width="1"> <input type="radio" name="rdOperation" onclick="return radio_onclick(4)"> </td>
<td width="1">
<input type="checkbox" name="chkDel" value="4|VT|L~"></td>
<td class="center">
VT</td>
<td class="center">
L</td>
<td class="left">
Truck </td>
<td class="center">
Y</td>
<td class="center">
A</td>
<td class="left">
APIMPORT</td>
<td class="left">
20-sep-2013</td>
</tr>
<!-- Printing -->
<!-- QT="VL" QC="KD" -->
<!-- UpdateId:VKUMARAG -->
<input type="hidden" name="QualifierType5" value="VL">
<input type="hidden" name="QualifierCode5" value="KD">
<input type="hidden" name="Print5" value="Y">
<tr id="tr5"><td width="1"> <input type="radio" name="rdOperation" onclick="return radio_onclick(5)"> </td>
<td width="1">
<input type="checkbox" name="chkDel" value="5|VL|KD~"></td>
<td class="center">
VL</td>
<td class="center">
KD</td>
<td class="left">
RANGER ICA </td>
<td class="center">
Y</td>
<td class="center">
A</td>
<td class="left">
VKUMARAG</td>
<td class="left">
23-apr-2020</td>
</tr>
<input type="hidden" name="QualifierType6" value="VL">
<input type="hidden" name="QualifierCode6" value="K#">
<input type="hidden" name="Print6" value="Y">
<tr id="tr6"><td width="1"> <input type="radio" name="rdOperation" language="javascript" onclick="return radio_onclick(6)"> </td>
<td width="1">
<input type="checkbox" name="chkDel" value="6|VL|K#~"></td>
<td class="center">
VL</td>
<td class="center">
K#</td>
<td class="left">
RANGER OLD </td>
<td class="center">
Y</td>
<td class="center">
A</td>
<td class="left">
APIMPORT</td>
<td class="left">
20-sep-2013</td>
</tr>
</tbody>
Try using css attribute = value selectors with contains operator (*). That way you can specify the static part of attribute value to match on, along with the node type attribute.
E.g.
ie.document.querySelector("[type=checkbox][value*='0|MY|2018']").click
Here I assume that 0|MY|2018 is static within the target node.

how i can select data from a combo box and fires onchange command using VBA-excel

i want to select "56 - Hoyer (Suk / Rontec)" in the combo box and then fire the event that reloads the page using VBA excel, i can put the text on the combo box, but it doesnt load tha javascript attached to it (onchange event).
see image of the drop down / combo box here
below is the code i use in VBA to fill out the combobox with a constant value. but i cannot run the onchange event on html provided.
Call IE.document.getElementById("orders.carrier_number_txtSelectionDisplay").setAttribute("value", "56 - Hoyer (Suk / Rontec)")
Call IE.document.getElementById("orders.carrier_number_txtSelectionDisplay").setAttribute("value", "56 - Hoyer (Suk / Rontec)")
Set x = IE.document.getElementById(orders.carrier_number_txtSelectedValue)
x.Focus
x.FireEvent "onchange"
Below is the HTML code:
<td>
<div>
<span id="Descriptor.orders.carrier_number" class="dataentry-descriptor dataentry-descriptor-top" style="text-align:left;">Carrier</span>
</div>
<div class="dataentry-field-control" style="text-align:left;">
<div id="orders.carrier_number_4b7bc829-2760-4042-aab0-be8ccfb9541b" timerid="" querymethodname="GetSupplierCarriers">
<div id="orders.carrier_number_pnlSelectionDisplay" class="ffnet-combo-box dataentry-field required" style="width:180px;">
<table border="0" style="border-spacing: 0px; border-collapse: collapse; margin:0px;">
<colgroup>
<col style="width: 100%">
<col style="width: 30px; text-align: right;">
</colgroup>
<tbody>
<tr>
<td style="padding: 0px;">
<input name="orders.carrier_number$txtSelectionDisplay" type="text" id="orders.carrier_number_txtSelectionDisplay" class="dataentry-field required validate[required] required" isrequired="True" datatype="3"
onkeydown="javascript:return InputProcessKeyDown('orders.carrier_number_4b7bc829-2760-4042-aab0-be8ccfb9541b', event);" onfocus="javascript:return InputProcessOnFocus('orders.carrier_number_4b7bc829-2760-4042-aab0-be8ccfb9541b');
" style="width:150px;">
<input name="orders.carrier_number$txtSelectedValue" type="text" onchange="retrieveChildData("orders.carrier_number_4b7bc829-2760-4042-aab0-be8ccfb9541b","orders.loaded_driver_number_e5ba36ca-
aa0f-4f55-aa3e-c7cb342d0b0b"); retrieveChildData("orders.carrier_number_4b7bc829-2760-4042-aab0-be8ccfb9541b","orders.delivered_driver_number_e7747c68-df71-4774-9b04-
d897d1fd9833"); retrieveChildData("orders.carrier_number_4b7bc829-2760-4042-aab0-be8ccfb9541b","orders.vehicle_code_d3cc805c-e505-45c5-a351-98028439e34d"); retrieveChildData("orders.carrier_number_4b7bc829-
2760-4042-aab0-be8ccfb9541b","orders.tractor_number_089faa52-6810-4815-8f64-81eb201105a2"); UpdateDirtyBit(1);setTimeout('__doPostBack(\'orders.carrier_number$txtSelectedValue\',\'\')', 0)"
onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="orders.carrier_number_txtSelectedValue" datavaluefield="carrier_number" assembly="FFNET_CORE" funcname="OrderDispatch_DeleteOrderTrailer"
methodclass="CBL" hasautopostback="true" namespace="FBS" selectlistargs="{"SenderId":"orders.carrier_number","supplier_number":"139","RequiresParent":"True"}" style="display:none;">
</td>
<td>
<img id="orders.carrier_number_imgArrow" onclick="InputProcessOnFocus('orders.carrier_number_4b7bc829-2760-4042-aab0-be8ccfb9541b'); activeCB.toggleDropDown();" src="/ffnet/Images/DropDownListArrow.gif">
</td>
</tr>
</tbody>
</table>
</div>
<div id="orders.carrier_number_pnlDropDownList" class="ffnet-combo-box-ddlist" style="width:339px;">
<div id="orders.carrier_number_pnlDropDownRegion" class="ffnet-combo-box-ddregion" value="" style="width:339px;">
<table header="0" style="width:322px;" cellspacing="0" cellpadding="0">
<colgroup>
<col style="width:80px;">
<col style="width:210px;">
</colgroup>
<tbody>
<tr>
<th>Carrier Number</th>
<th>Name</th>
</tr>
</tbody>
</table>
<div id="orders.carrier_number_pnlDataRegion" class="ffnet-combo-box-data" style="width:339px;height:200px;">
<table style="width:322px;" onkeydown="javascript:return ProcessKeyDown(this, event);" tabindex="0" mode="combobox">
<colgroup>
<col style="width:80px;">
<col style="width:210px;">
</colgroup>
<tbody>
<tr id="orders.carrier_number_tr0" pk="1" text="1 - Armac Shipping" class="ffnet-combo-box-row-focus">
<td>1</td>
<td>Armac Shipping</td>
</tr>
<tr id="orders.carrier_number_tr1" pk="2" text="2 - IPCS Ltd">
<td>2</td>
<td>IPCS Ltd</td>
</tr>
<tr id="orders.carrier_number_tr23" pk="56" text="56 - Hoyer (Suk / Rontec)">
<td>56</td>
<td>Hoyer (Suk / Rontec)</td>
</tr>
</tbody>
</table>
</div>
<div id="orders.carrier_number_pnlPager" class="ffnet-combo-box-paging" title="Click for more records" onclick="RetrieveNextPage($("[id$='orders.carrier_number_4b7bc829-2760-4042-aab0-be8ccfb9541b']").get(0), false);
" recordcount="129">
1-30 of 129 results
</div>
</div>
</div>
</div>
<input type="hidden" name="orders.carrier_number_txtSelectedValue_hdnDirtyBit" id="orders.carrier_number_txtSelectedValue_hdnDirtyBit" value="0">
</div>

Find label name which doesn't contain input immediately from a table

I am having a table which contains multiple td/tr.
My problem is label which i want to get doesn't contains input immediately neither that label has any attributes property.
I want to get "Countries of Permanent Residence" and Dates which are in span but doesn't have any properties that span is in div that too doesn't contains any property.
I tried with
formElement[input[name="icims_gh_Permanent_Country_Residence"]]
But don't know how to get associate label.
Html looks like:
<div style="margin:0px">
<table style="width:100%" border="1" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td valign="top">
<div style="margin:0px">
<span style="font-family:arial,helvetica,sans-serif;font-size:12px"> Countries of Permanent Residence (list all) </span>
</div>
</td>
<td valign="top">
<div style="margin:0px">
<span style="font-family:arial,helvetica,sans-serif;font-size:12px"> Dates </span>
</div>
</td>
</tr>
<tr>
<td colspan="2" valign="top">
<div style="margin:0px">
<div>
<input type="hidden" name="icims_gh_Permanent_Country_Residence" value="1">
<a name="0.1_icims_ga_Permanent_Country_Residence"></a>
<div>
<table style="width:100%;border:0px">
<tbody>
<tr>
<td>
<table style="width:100%" border="1" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td valign="top">
<div style="margin:0px">
<span style="font-family:arial,helvetica,sans-serif;font-size:12px">
<input type="text" name="icims_0_permResidenceCountry"> </span>
</div>
</td>
<td valign="top">
<div style="margin:0px">
<span style="font-family:arial,helvetica,sans-serif;font-size:12px">
<input type="text" name="icims_0_permResidenceCountryDates"> </span>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>

Number of Search Results from Excel

Given a column of strings I would like to find the number of search results from a website (e.g. sciencedirect.com) for each string. An existing answer Number of Google Results from Excel works well for Google.
Unfortunately this solution creates the search URL from the string i.e. a Google search for example contains the word example. The sites I want to use do not do this.
A search for example returns the URL http://www.sciencedirect.com/science?_ob=ArticleListURL&_method=list&_ArticleListID=1860967815&_sort=r&_st=13&view=c&_acct=C000053194&_version=1&_urlVersion=0&_userid=1495569&md5=0ef30742e917da15236ef1824058a1db&searchtype=a
Any idea how I achived the same result with this type of search engine.
You'll have to examine the form you submit when you click on the Search button. The form sends a GET request which containes the search terms, but then you get redirected to the result list page, and the URL of the results page does not contain the search terms any more.
I have successfully searched for "corpus" with this URL:
http://www.sciencedirect.com/science?_ob=QuickSearchURL&_method=submitForm&_acct=C000228598&_origin=home&_zone=qSearch&md5=61ce8901b141d527683913a240486ac4&qs_all=corpus
Note that what you'll have to do is
download the start page http://www.sciencedirect.com/
extract hidden fields from the search form
assemble the search URL from the hidden fields
add your search term to the search URL in the qs_all field
send GET request with the search URL
follow redirection
Except for qs_all all other fields in this URL comes from the the form as hidden fields.
This is the source of the corresponding form, as I downloaded it (before sending the "corpus" search request.):
<form name="qkSrch" method="get" target="_top" action="/science" style="margin:0px;">
<input type="hidden" name="_ob" value="QuickSearchURL">
<input type="hidden" name="_method" value="submitForm">
<input type="hidden" name="_acct" value="C000228598">
<input type="hidden" name="_origin" value="home">
<input type="hidden" name="_zone" value="qSearch">
<input type="hidden" name="md5" value="61ce8901b141d527683913a240486ac4">
<table border="0" width="100%" cellpadding="0" cellspacing="0" style="margin: 0;">
<tbody><tr valign="middle">
<!-- Code related for toggling labels -->
<td align="right"><label for="qs_all" id="fieldLabel"> All fields</label></td>
<td align="left"><input class="textbox qsinput xpstyle" type="text" name="qs_all" id="qs_all" value="" size="30" maxlength="450" title="For example: heart attack AND behavior?" tabindex="1"></td>
<td align="right"><label for="qs_author"> Author</label></td>
<td align="left" colspan="5"><input class="textbox qsinput xpstyle" type="text" name="qs_author" id="qs_author" value="" size="33" maxlength="450" title="e.g. J S Smith or John Smith or Smith JS" tabindex="2" style="_width:100%"></td>
<td nowrap="nowrap">
</td><td></td><td></td>
<td align="right" nowrap="nowrap" width="90%" valign="middle">
Advanced search
</td>
</tr>
<tr>
<td align="right"><label for="qs_title"> Journal/Book title</label></td>
<td align="left"><input class="textbox qsinput xpstyle" type="text" id="qs_title" name="qs_title" value="" size="30" maxlength="450" title="For example: journal of molecular biology" tabindex="3"></td>
<td align="right" class="toggleQukSrch2"><label for="qs_vol" id="volField"> Volume</label></td>
<td align="left" class="toggleQukSrch"><input class="textbox qsinput xpstyle" type="text" name="qs_vol" id="qs_vol" value="" size="3" maxlength="10" style="width:30px;" tabindex="4"></td>
<td align="right" class="toggleQukSrch2"><label for="qs_issue" id="issueField"> Issue</label></td>
<td align="left" class="toggleQukSrch"><input class="textbox qsinput xpstyle" type="text" name="qs_issue" id="qs_issue" value="" size="3" maxlength="10" style="width:30px" tabindex="5"></td>
<td align="right" class="toggleQukSrch2"><label for="qs_pages" id="pageField"> Page</label></td>
<td align="right" class="toggleQukSrch"><input class="textbox qsinput xpstyle" type="text" name="qs_pages" id="qs_pages" value="" size="3" maxlength="10" title="For example: 14-27" style="width:30px" tabindex="6"></td>
<td align="right" nowrap="nowrap">
<input class="button" id="submit_search" type="Submit" alt="Submit Quick Search" title="Submit Quick Search" value="Search ScienceDirect" tabindex="8" name="sdSearch">
</td>
<td align="right" nowrap="nowrap" colspan="8" valign="bottom">
<a class="icon_qmarkHelpsci_dir" href="/science?_ob=HelpURL&_file=qs_tips.htm&_acct=C000228598&_version=1&_urlVersion=0&_userid=10&md5=2bd779305b31602341744eaa786e2f0a" target="sdhelp" onmouseover="window.status='Help is Available';return true" onmouseout="window.status='';return true" onclick="var helpWin;helpWin=window.open('/science?_ob=HelpURL&_file=qs_tips.htm&_acct=C000228598&_version=1&_urlVersion=0&_userid=10&md5=2bd779305b31602341744eaa786e2f0a','sdhelp','scrollbars=yes,resizable=yes,directories=no,toolbar=no,menubar=no,status=no,width=760,height=570');helpWin.focus();return false" tabindex="9" style="font-size:0.92em;padding-right:0;">Search tips</a>
</td>
</tr>
</tbody></table>
</form>
EDIT
Continued with How to extract the number of results from the results page.
Your assumption is right, you'll have to change other parts of the code, namely that extracts the number of results value.
Let's stick with the previous example.
When searching from "corpus", you will find this line in the source of the result page:
<input type="hidden" name="TOTAL_PAGES" value="2836">
And you'll want to extract 2836. Hence you will search for something like <input type="hidden" name="TOTAL_PAGES" value=" and get the subequent value before the closing quote.
I am not going to tell you how to code in VBA, but it is basic String manipulation so I hope you can handle it.

Resources