J'essaye d'automatiser l'accès à une page Web avec VBA. Je suis dans l'écran de connexion, mais je ne peux pas cliquer sur l'un des éléments pour accéder à l'écran de recherche. Normalement, ce n'est pas trop difficile, mais il semble que cet élément soit dans une iframe? Je ne sais pas si c'est pourquoi je ne peux pas le voir. J'ai essayé de boucler toutes les balises A et d'obtenir des retours nop. J'ai essayé d'utiliser le sélecteur de requête pour l'atteindre, ce qui m'a été montré dans le passé et a fonctionné. Les deux en vain. J'ai essayé 4 façons différentes de saisir une balise avec l'idée de faire une boucle ForEach après avoir fait correspondre un attribut et cliquer:
Set HTMLAs = HTMLDoc.getElementsByTagName("a")
Set HTMLAs = HTMLDoc.getElementsByTagName("tr")
Set HTMLAs = HTMLDoc.getElementsByTagName("td")
Set HTMLAs = HTMLDoc.getElementsByTagName("div")
Et j'ai essayé:
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
et aucun de ceux-ci ne saisit l'élément.
Voici le html de l'élément sur lequel je veux cliquer:
<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>
et voici le haut du cadre lorsque j'arrive pour la première fois sur la page que je veux:
<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>
Mais à partir de là, je ne sais pas trop comment procéder. Tout conseil ou direction très apprécié.
Capture d'écran du code HTML de l'iframe à la politique de recherche. Capture d'écran
Formulaire de recherche après avoir cliqué sur "Politique de recherche"
<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>
Lorsque je clique sur la page Web qui contient les quelques options de recherche / navigation:
<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>
Le sélecteur est correct
a[title=Policy]
S'il y a un frame / iframe, utilisez l'une de ses propriétés pour accéder à son contentDocument. Par exemple, s'il y a un identifiant pour la trame
ie.document.getElementById(frameid").contentDocument.querySelector("a[title=Policy]").click
Cet article est collecté sur Internet, veuillez indiquer la source lors de la réimpression.
En cas d'infraction, veuillez [email protected] Supprimer.
laisse moi dire quelques mots