I am trying to automate access to a web page with VBA. I am in thru the login screen, but I am not able to click one of the elements to get to the search screen. Normally this isn't too hard, but it seems like this element is in an iframe? I'm not sure if that is why I can't see it. I've tried to loop all the A tags and get nop returns. I've tried to use query selector to reach it which i was shown in the past and worked. Both to no avail. I've tried 4 different ways to grab a tag with the idea of doing a ForEach loop after & matching some attribute & clicking:
Set HTMLAs = HTMLDoc.getElementsByTagName("a")
Set HTMLAs = HTMLDoc.getElementsByTagName("tr")
Set HTMLAs = HTMLDoc.getElementsByTagName("td")
Set HTMLAs = HTMLDoc.getElementsByTagName("div")
And i've tried:
HTMLDoc.querySelector("a[title='Policy']").Click
'HTMLDoc.querySelector("a[href='/PolicySearch/policySearch_v30.cfm?module=policy&actionType=lookup']").Click 'no
'HTMLDoc.querySelector("a[href='/PolicySearch/policySearch_v30.cfm?module=policy&actionType=lookup']").Click 'no
'HTMLDoc.querySelector("A[href='/PolicySearch/policySearch_v30.cfm?module=policy&actionType=lookup']").Click 'NO
'HTMLDoc.querySelector("A[title='Policy']").Click 'no
and none of those grab the element.
This is the html of the element i want to click:
<A title=Policy style="FONT-SIZE: 8pt; FONT-FAMILY: arial"
href="/PolicySearch/policySearch_v30.cfm?
module=policy&actionType=lookup" target=main nowrap> Lookup Policy
</A>
and this is the top of the frame when i first get on the page i want:
<FRAMESET id=defaultFrame frameSpacing=0 border=0 frameBorder=no
rows=70,21,*,21,1><FRAME noResize src="/systemInfo/ScriptX/titleBar.cfm"
frameBorder=0 name=titleBar scrolling=no application="yes"><FRAME noResize
src="/producerTOC.cfm" frameBorder=0 name=producerTOC scrolling=no
application="yes"><FRAMESET id=BottomRow cols=1,*><FRAME noResize
src="toc.cfm" frameBorder=0 name=toc marginWidth=0 scrolling=no
application="yes"><FRAME noResize src="main.cfm" frameBorder=0 name=main
application="yes"></FRAMESET><FRAME noResize
src="/systemInfo/ScriptX/footerFrame.cfm" frameBorder=0 name=footerFrame
scrolling=no application="yes"><FRAME noResize src="" frameBorder=0
name=utilityFrame scrolling=no application="yes"><NOFRAMES></NOFRAMES>
But from here i'm not sure how to proceed. Any advice or direction much appreciated.
Screenshot of html from the iframe down to Lookup Policy. ScreenShot
Search form after clicking "Lookup Policy"
<FORM id=SearchForm onsubmit="return _CF_checkSearchForm(this)" method=get
name=SearchForm action=/PolicySearch/policyAdvLookup_v30.cfm
target=searchResultFrame><TABLE class=TableSelection>
<TBODY>
<TR>
<TD class=HeaderCell>Policy Search</TD></TR>
<TR>
<TD class=SelectionCell>
<TABLE class=NoBorder>
<TBODY>
<TR>
<TD class=Right style="WIDTH: 2%" noWrap> </TD>
<TD class="Right Bold" style="WIDTH: 20%" noWrap>Search Criteria</TD>
<TD noWrap><A onclick="ToggleMode();return false;" id=ToggleModeLink
class=FloatR href="">- Advanced Search -</A> <INPUT onfocus=this.select();
id=searchField class=upperCase size=30 name=searchField class="upperCase"
jQuery112406813183503798275="4"><BUTTON id=SearchButton style="WIDTH: 130px"
type=submit name=SearchButton>Search</BUTTON></TD></TR>
<TR>
<TD id=SearchLabel class="Right Bold" colSpan=2 noWrap>Search By</TD>
<TD noWrap><INPUT onclick=LoadParam(1); id=searchOption title="Policy # /
Name" class=Blend CHECKED type=radio value=name name=searchOption>Policy # /
Name <INPUT onclick=LoadParam(2); id=searchOption title="Insured
Address" class=Blend type=radio value=address name=searchOption>Insured
Address <INPUT onclick=LoadParam(3); id=searchOption title="Dwelling
Location" class=Blend type=radio value=location name=searchOption>Dwelling
Address
<DIV id=LineSearchOptions><SPAN id=LineSearchOptions_1
name="LineSearchOptions_1"><INPUT onclick=LoadParam(6,true); id=searchOption
title="Driver Name / Lic Num" class=Blend type=radio value=name
name=searchOption>Driver Name / Lic Num <INPUT
onclick=LoadParam(6,false); id=searchOption title="Vehicle VIN" class=Blend
type=radio value=VIN name=searchOption>Vehicle VIN </SPAN></DIV></TD>
</TR>
<TR id=PolicyTypeRow name="PolicyTypeRow">
<TD class="Right Bold" colSpan=2 noWrap>Policy Type</TD>
<TD noWrap><SELECT onchange=ShowLineOptions(this.value); id=policyType
name=policyType> <OPTION selected value=0>All Policy Types</OPTION> <OPTION
value=4>Homeowner Policies</OPTION> <OPTION value=3>Dwelling Fire
Policies</OPTION> <OPTION value=1>Personal Auto Policies</OPTION></SELECT>
</TD></TR>
<TR id=SearchCriteriaDisplay name="SearchCriteriaDisplay">
<TD class=Right noWrap><A onclick="ClearParam(1);return false;" id=aClear
href="" name=aClear>[ X ]</A></TD>
<TD id=strSearchParamLbl class="Right Bold" noWrap
name="strSearchParamLbl">Policy # / Name</TD>
<TD noWrap><SPAN id=strSearchParamDisplay name="strSearchParamDisplay">
</SPAN><INPUT id=strSearchParam type=hidden name=strSearchParam></TD></TR>
<TR id=SearchCriteriaDisplay name="SearchCriteriaDisplay">
<TD class=Right noWrap><A onclick="ClearParam(2);return false;" id=aClear
href="" name=aClear>[ X ]</A></TD>
<TD id=strSearchParamLbl class="Right Bold" noWrap
name="strSearchParamLbl">Insured Address</TD>
<TD noWrap><SPAN id=strSearchParamDisplay name="strSearchParamDisplay">
</SPAN><INPUT id=strSearchParam type=hidden name=strSearchParam></TD></TR>
<TR id=SearchCriteriaDisplay name="SearchCriteriaDisplay">
<TD class=Right noWrap><A onclick="ClearParam(3);return false;" id=aClear
href="" name=aClear>[ X ]</A></TD>
<TD id=strSearchParamLbl class="Right Bold" noWrap
name="strSearchParamLbl">Dwelling Location</TD>
<TD noWrap><SPAN id=strSearchParamDisplay name="strSearchParamDisplay">
</SPAN><INPUT id=strSearchParam type=hidden name=strSearchParam></TD></TR>
<TR id=SearchCriteriaDisplay name="SearchCriteriaDisplay">
<TD class=Right noWrap><A onclick="ClearParam(4);return false;" id=aClear
href="" name=aClear>[ X ]</A></TD>
<TD id=strSearchParamLbl class="Right Bold" noWrap
name="strSearchParamLbl">Phone </TD>
<TD noWrap><SPAN id=strSearchParamDisplay name="strSearchParamDisplay">
</SPAN><INPUT id=strSearchParam type=hidden name=strSearchParam></TD></TR>
<TR id=TimeframeRow name="TimeframeRow">
<TD class="Right Bold" colSpan=2 noWrap>Recent Policies Only</TD>
<TD noWrap><INPUT id=historyTimeFrame CHECKED type=checkbox value=1200
name=historyTimeFrame> Exclude policies that expired prior to December
1918</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><INPUT
id=strSearchNameNum type=hidden name=strSearchNameNum> <INPUT
id=strSearchAddress type=hidden name=strSearchAddress> <INPUT
id=strSearchLocation type=hidden name=strSearchLocation> <INPUT
id=strSearchPhone type=hidden name=strSearchPhone> <INPUT
id=strSearchEmail type=hidden name=strSearchEmail> <INPUT id=strSearchLine
type=hidden name=strSearchLine> <INPUT id=strSearchLineType type=hidden
name=strSearchLineType> <INPUT id=displayType type=hidden value=0
name=displayType> <INPUT type=hidden value=0 name=isQuoteSearch> <INPUT
type=hidden value=policy name=module> <INPUT type=hidden value=lookup
name=actionType> </FORM>
When i Click on the webpage that holds the few search/navigate options:
<FRAMESET id=defaultFrame frameSpacing=0 border=0 frameBorder=no
rows=70,21,*,21,1><FRAME noResize src="/systemInfo/ScriptX/titleBar.cfm"
frameBorder=0 name=titleBar scrolling=no application="yes"><FRAME noResize
src="/producerTOC.cfm" frameBorder=0 name=producerTOC scrolling=no
application="yes"><FRAMESET id=BottomRow cols=1,*><FRAME noResize
src="toc.cfm" frameBorder=0 name=toc marginWidth=0 scrolling=no
application="yes"><FRAME noResize src="main.cfm" frameBorder=0 name=main
application="yes"></FRAMESET><FRAME noResize
src="/systemInfo/ScriptX/footerFrame.cfm" frameBorder=0 name=footerFrame
scrolling=no application="yes"><FRAME noResize src="" frameBorder=0
name=utilityFrame scrolling=no application="yes"><NOFRAMES></NOFRAMES>
</FRAMESET>
Table:
<TABLE id=MainTabText style="BORDER-TOP: 0px; HEIGHT: 19px; BORDER-RIGHT:
0px; WIDTH: 100%; BORDER-BOTTOM: 0px; LEFT: 0px; MARGIN: 0px; BORDER-LEFT:
0px; TOP: 0px" cellSpacing=0 cellPadding=0 name="MainTabText"><TBODY>
<TR style="FONT-WEIGHT: bold">
<TD style="FONT-SIZE: 8pt; BORDER-TOP: 0px; FONT-FAMILY: arial; BORDER-
RIGHT: 0px; WIDTH: 1%; VERTICAL-ALIGN: middle; BORDER-BOTTOM: 0px; COLOR:
black; PADDING-BOTTOM: 0px; TEXT-ALIGN: left; PADDING-TOP: 0px; PADDING-
LEFT: 10px; BORDER-LEFT: 0px; LINE-HEIGHT: 8pt; PADDING-RIGHT: 0px" noWrap>|
<A title=Policy style="FONT-SIZE: 8pt; FONT-FAMILY: arial"
href="/PolicySearch/policySearch_v30.cfm?
module=policy&actionType=lookup" target=main nowrap> Lookup Policy
</A> |<A title=Reports style="FONT-SIZE: 8pt; FONT-FAMILY: arial"
href="/Reports/reports.cfm" target=main nowrap> Reports </A> |<A
title=Agencies style="FONT-SIZE: 8pt; FONT-FAMILY: arial"
href="ProducerInfo/producerInfoLayout.cfm?producerID=10003" target=main
nowrap> Agency Info </A> |<A title="Upload Documents"
style="FONT-SIZE: 8pt; FONT-FAMILY: arial"
href="/PolicySearch/policySearch_v30.cfm?
module=Upload&actionType=lookup" target=main nowrap> Upload
Documents </A> |<A title="Batch Viewer" style="FONT-SIZE: 8pt; FONT-
FAMILY: arial" href="/batch/batchViewer/batchViewerlayout.cfm" target=main
nowrap> Batch Viewer </A> |</TD>
<TD style="FONT-SIZE: 8pt; BORDER-TOP: 0px; FONT-FAMILY: arial; BORDER-
RIGHT: 0px; WIDTH: 99%; VERTICAL-ALIGN: middle; BORDER-BOTTOM: 0px; COLOR:
black; PADDING-BOTTOM: 0px; TEXT-ALIGN: right; PADDING-TOP: 0px; PADDING-
LEFT: 0px; BORDER-LEFT: 0px; LINE-HEIGHT: 8pt; PADDING-RIGHT: 10px"
noWrap> | <A style="FONT-SIZE: 8pt; FONT-FAMILY: arial"
href="/main.cfm" target=main nowrap> Home </A> | <A
onclick="LogoutCheck();blur();return false;" style="FONT-SIZE: 8pt; FONT-
FAMILY: arial" href="" nowrap> Logout </A> |</TD></TR></TBODY>