Jump to content

Click Link Using href


Recommended Posts

So I need to be able to click a link given an href. I did some searching on the forum and was able to find some code which, from my understanding, finds all of the links on the current page and then cycles through them. I know that it is picking up the link that I need to click because it shows up in the pop box, but I am unable to actually get the "click" to go through. Here is the code that I'm referencing, where $oHref is the href of the link that I need to click:

 

  _IELinkGetCollection($oIE)
  Local $oLinks = _IELinkGetCollection($oIE)
  Local $iNumLinks = @extended
  MsgBox(0, "Link Info", $iNumLinks & " links found")
  For $oLink In $oLinks
  MsgBox(0, "Link Info", $oLink.href)
  If $oLink.href = $oHref Then
     _IEAction($oLink, "click")
   
  ExitLoop
  EndIf
  Next

Any ideas on what I am missing?

Also, here is the original post that I'm looking at: https://www.autoitscript.com/forum/topic/143882-ie-click-link-by-href/

 

Link to comment
Share on other sites

Hey MichaelHB,

So the website is medicare.gov and I am using it to view various medicare pharmacy plans. I have written a script that allows me to make various selections and navigate the site (picking a zip-code, picking drugs I am taking, etc.) up to the point that I need to select a pharmacy. You do so by clicking a link below your desired pharmacy. The HTML for a pharmacy looks like:

<div class="pharmacy">
                      <span name="pharmacy" phone="1-305-595-3546" zip="33173" state="FL" city="Miami" address="11690 Sw 72Nd St" pharmacyname="Walgreens" latitude="25.7000064849854" longitude="-80.3816604614258"></span>
                                      
                      
                        <div class="pharmacyAttrContainer">
                            <p>
                            <b>Walgreens</b><br>
                            11690 Sw 72Nd St <br>
                            Miami, FL 33173<br>
                            1-305-595-3546
                            </p>
                            <p> <a href="/pfdn/SharedPharmacy/AddRetailPharmacy?vid=a98QSGvm1WaDvBN8m13%2FF4vHVe2cjlD9mkBdtkUzV%2FUpjAV0M32pQ7drEB1Hjdfs4CAQnz1yH0LTjEhCj3TI1A%3D%3D&amp;pharmacyNABP=1048380&amp;language=English&amp;PlanFinderDRxIntegrationId=65af9d9447f74573b173afcc0c2098d8831315697615" data-ajax-update="#divMyRetailPharmacies" data-ajax-success="UpdateSearchPharmacyList" data-ajax-mode="replace" data-ajax-method="post" data-ajax="true">Add Pharmacy<span class="HiddenText"> Walgreens</span></a></p>
                                  
                            </div>
                        
                    </div>

I can't post the link directly to the page because you must enter your zip code and drug information before arriving at this page--sorry about that.

Perhaps I am oversimplifying things, but is there no way to use an href to create an object that I can then just click?

Thanks.

 

Link to comment
Share on other sites

1 hour ago, MichaelHB said:

Hello @newuser1234, did you try this?

_IELinkClickByText($oIE, "Add Pharmacy Walgreens")

 

I had tried that and unfortunately it did not work :(. I tried everything that I could think of using the string "Add Pharmacy" and have yet to have any luck, and that's why I was hoping that I could use the href for the link somehow.

 

Link to comment
Share on other sites

You said that you can't post the link directly to the page because you must enter your zip code and drug information before arriving at that page, so just input a different zip code just for simulation so i can see all the html, if there is a frame or something else. Its easier than i try to guess, because with just that piece of the html the _IELinkClickByText works. And i cant know how are you comparing to determine whether the href link interests you or not.

Link to comment
Share on other sites

<div class="mocWrapper mocWrapperNoMap" id="divMainContainer">
        <a name="main_content" tabindex="-1" id="main content"></a>
        <div class="PlanFinderHeaderStyle">
            <h1 class="planFinderTitle2" id="Tool_header">
                Step 3 of 4: Select Your Pharmacies
            </h1>
            <div class="PHPDHeaderStyle" id="ctl00_ctl00_ctl00_MCGMainContentPlaceHolder_ToolContentPlaceHolder_toolHeaderPanel">
                
                <p>
                    Please select up to two pharmacies to get a better estimate of how much your prescription drugs will cost.  If your pharmacy isn’t in a plan’s network, the cost you will see is the full price of the drug with no insurance.  Also note that some plans offer lower drug prices at preferred network pharmacies, compared to other pharmacies in the network.</p>
                
            </div>
            <!--PHPDHeaderStyle-->
        </div>
        <div class="control_container">
            <div class="ctrl_profile">
                
<div class="CurrentProfileWidgetStyle" id="PlanFinderContentWidget">
<div class="CurrentProfileWidgetDiv" id="CurrentProfileWidget">
    <div class="CurrentProfileWidgetUserControl" id="currentProfileWidget">
       <div class="CurrentProfileWidgetUserControlInner">
            
            <div class="WidgetContainerPanel" id="WidgetContainerPanel" name="WidgetContainerPanel">
                <div class="WidgetContainerPanelInner" id="collapseablePanel" style="height: auto; visibility: visible;">
                    
                    <div id="CurrentProfileRegular">
                        <div title="Access My Current Profile" class="ajax__tab_xp ajax__tab_container ajax__tab_default">
                            <div class="ajax__tab_active">
                                <div class="ajax__tab_outer">
                                    <div class="ajax__tab_inner">
                                        <div class="ajax__tab_tab">
                                                <div class="CurrentProfileWidgetCollapseExpand" id="ShowHideWidget_Panel">
                                                  <a tabindex="0" title="Collapse My Current Profile" class="TabSelectedLabel" id="likCurrentMemberProfileExpand" href="#">
                                                        <img title="Collapse My Current Profile" id="widgetHideShowImage" alt="Collapse" src="https://plancompare.medicare.gov/pfdn/SharedResources/shared/images/collapse-new.png">My Current Profile
                                                  </a>
                                                </div>
                                        </div>
                                    </div>
                               </div>
                             </div>
                         </div>
                   </div>
               </div>
                        <div class="ajax__tab_xp">
                            <div>
                                <!--
                                <div class="ajax__tab_outer">
                                    <div class="ajax__tab_inner">
                                        <div class="ajax__tab_tab">
                                            Additional Tools
                                        </div>
                                        
                                    </div>
                                </div>
                                -->
                            </div>
                        </div>
                        <div class="clearBlock"><br></div>
                        <div class="widget-tab-content ajax__tab_body" id="currentProfilePanel" name="currentProfilePanel">
                            <div id="widgetContentProfile">
                                <br>
                                <ul>
                                    <li>
                                        <span class="profileToolsWidgettext">Zip Code:</span>&nbsp;33173
                                    </li>
                                    
                                    <li>
                                        <span class="profileToolsWidgettext">Current Coverage:</span>&nbsp;Unknown
                                    </li>
                                    
                                          <li>                                          
                                          <span class="profileToolsWidgettext">Current Subsidy:</span>&nbsp;No Extra Help 
                                          
                                                <a href="javascript:openWindow(glossaryURL('0051','English'));">[?]
                                                    <span class="HiddenText">Glossary Definition For No Extra Help - Opens in a new window</span>
                                                </a>
                                          </li>
                                          
                                        <li><span class="profileToolsWidgettext">
                                            Drug List ID:
                                        </span>&nbsp;4923432128
                                        </li>
                                        
                                        <li><span class="profileToolsWidgettext">
                                            Password Date:
                                        </span>&nbsp;05/02/2016
                                        </li>
                                        
                                    </ul>
                                    
                                    <div class="widget-center">
                                        <a tabindex="0" title="Important Coverage Information" class="ImportantLabel" href="javascript:openWindow('http://www.medicare.gov/find-a-plan/staticpages/plan-messages.aspx?Language=English','PlanMessageWindow','left=0,top=0,height=600,width=1000,menubar=0,resizable=1,scrollbars=1');" alt="Important Coverage Information">
                                            Important Coverage Information
                                        </a>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="clearBlock">
                        </div>
                        
                    </div>
                </div>
            </div>
        </div>
<br>



            </div>
        </div>
        <br style="clear: both;">
        <div id="pharmacySearchBtnBlock">
                
            <div class="rightButton">
            <div id="jaws_errror_message" style="color: red; padding-bottom: 5px; font-size: 1.1em; font-weight: bold; display: none;">
                <h2 id="prefaceError">Please correct the following errors.</h2>
                <ul>
                    <li>Error: Please select a pharmacy</li>
                </ul>
            </div>           
                <a tabindex="0" title="Continue to Plan Results" class="linkButtonOrange" id="btnContinueToPlanResult_Top"><span>
                        Continue to Plan Results</span></a>
            </div>
        </div>
        <div id="Content-wrap">
            <div id="PlanFinderContent">            
    <div id="topCorners"></div>
    <div class="portMainPharmacies">
    <div class="roundTop"></div>
    <div class="portContent">
        
<div class="drx_radius_dropdown">
<form id="frmRadius" action="/pfdn/" method="post"><input name="Location" id="Location" type="hidden" value="33173"><input name="VID" id="VID" type="hidden" value="a98QSGvm1WaDvBN8m13/F4vHVe2cjlD9mkBdtkUzV/UpjAV0M32pQ7drEB1Hjdfs4CAQnz1yH0LTjEhCj3TI1A=="><input name="MinLat" id="MinLat" type="hidden" value="25.7000064849854"><input name="MaxLat" id="MaxLat" type="hidden" value="25.7000064849854"><input name="MinLon" id="MinLon" type="hidden" value="-80.3816604614258"><input name="MaxLon" id="MaxLon" type="hidden" value="-80.3816604614258"><input name="IsNetworkPharmacySearch" id="IsNetworkPharmacySearch" type="hidden" value="False"><input name="Language" id="Language" type="hidden" value="English"><input name="PlanFinderDRxIntegrationId" id="PlanFinderDRxIntegrationId" type="hidden" value="bf359df3eaa44466abf162f9fb567ee6831393915806"><input name="GeoCode" id="GeoCode" type="hidden" value="(25.7038331, -80.360297)"><input name="HasPreferredPharmacyNetwork" id="HasPreferredPharmacyNetwork" type="hidden" value="False"><input name="HasRetailPreferred" id="HasRetailPreferred" type="hidden" value="False"><input name="PharmacyName" id="PharmacyName" type="hidden" value="Walgreens"><input name="PharmacyName" id="PharmacyName" type="hidden" value="Walgreens"><input name="ShowMap" id="ShowMap" type="hidden" value="False"><input name="IsPrintMode" id="IsPrintMode" type="hidden" value="False">
        <div class="results">
        <label for="TargetRadius">We found <span class="result" id="spanRecordCount">1</span> pharmacies within
        <span id="divRadiusSlection" name="divRadiusSlection">
             <select name="TargetRadius" id="TargetRadius"><option selected="true" value="0.25">0.25</option><option value="1.25">1.25</option><option value="1.75">1.75</option><option value="2">2</option></select>
             
        </span>
        miles of
        <span>33173</span>
         
         </label>
        </div>
 </form>
</div>
<a tabindex="0" class="linkButtonGeneric" id="lnkSearchNewLocation" href="#"><span>Search New Location or by Pharmacy Name</span></a>
<div class="bigTextPharmacyPopUp" id="divPharmacySearchContainer" style="display: none;">
<fieldset class="drx-normalfontsize">
    <form id="frmPharmacySearch" action="/pfdn/PlanFinder/PharmacySearch" method="post"><input name="PlanFinderDRxIntegrationId" id="PlanFinderDRxIntegrationId" type="hidden" value="bf359df3eaa44466abf162f9fb567ee6831393915806"><input name="Zip" id="Zip" type="hidden" value="33173"><input name="County" id="County" type="hidden" value="12086|MIAMI-DADE"><input name="SearchType" id="SearchType" type="hidden" value="General"><input name="FontSize" id="FontSize" type="hidden" value="smallFont"><input name="Language" id="Language" type="hidden" value="English"><input name="ContractYear" id="ContractYear" type="hidden" value="2016"><input name="ViewType" id="ViewType" type="hidden" value="PUBLIC"><input name="USER_CONFIRMATIONNUMBER" id="USER_CONFIRMATIONNUMBER" type="hidden" value="4923432128"><input name="USER_DATE_YEAR" id="USER_DATE_YEAR" type="hidden" value="2016"><input name="USER_DATE_MONTH" id="USER_DATE_MONTH" type="hidden" value="05"><input name="USER_DATE_DAY" id="USER_DATE_DAY" type="hidden" value="02"><input name="EnrollmentNumber" id="EnrollmentNumber" type="hidden" value="0"><input name="VID" id="VID" type="hidden" value="a98QSGvm1WaDvBN8m13/F4vHVe2cjlD9mkBdtkUzV/UpjAV0M32pQ7drEB1Hjdfs4CAQnz1yH0LTjEhCj3TI1A=="><input name="SubsidyLevel" id="SubsidyLevel" type="hidden" value="4"><input name="SubsidyPercent" id="SubsidyPercent" type="hidden" value="0"><input name="LISCostShare" id="LISCostShare" type="hidden" value="0"><input name="HostName" id="HostName" type="hidden" value="http://www.medicare.gov"><input name="noLISCostShareFlag" id="noLISCostShareFlag" type="hidden" value="False"><input name="CSRNotes" id="CSRNotes" type="hidden" value=""><input name="CURRENT_COVERAGE" id="CURRENT_COVERAGE" type="hidden" value="Unknown"><input name="CURRENT_SUBSIDY" id="CURRENT_SUBSIDY" type="hidden" value="No Extra Help"><input name="SP_CURRENT_COVERAGE" id="SP_CURRENT_COVERAGE" type="hidden" value="Desconocido"><input name="SP_CURRENT_SUBSIDY" id="SP_CURRENT_SUBSIDY" type="hidden" value="No elegible para subsidio"><input name="IMPORTANT_COVERAGE" id="IMPORTANT_COVERAGE" type="hidden" value="Important Coverage Information"><input name="SP_IMPORTANT_COVERAGE" id="SP_IMPORTANT_COVERAGE" type="hidden" value="Información importante acerca de la cobertura"><input name="CURRENT_SUBSIDY_LINK" id="CURRENT_SUBSIDY_LINK" type="hidden" value="0051"><input name="FUTURE_SUBSIDY_LINK" id="FUTURE_SUBSIDY_LINK" type="hidden" value="0083"><input name="ApplicationType" id="ApplicationType" type="hidden" value="PlanFinder"><input name="IsAllowedToGoPDE" id="IsAllowedToGoPDE" type="hidden" value="False">
                <legend>Search Criteria</legend>
                <p class="txtBoxAlign">

                    <span style="display: none;"><input name="Location" id="Location" type="hidden" value="33173">
                    </span>
                    <input id="newLocation" type="text">
                    <input name="GeoCode" id="GeoCode" type="hidden" value="(25.7038331, -80.360297)">
                    <label for="newLocation">Address or ZIP Code (Required): </label>
                 
                </p>
                <div class="clearBlock"></div>
                <p class="PharmacyNameTxtBox txtBoxAlign">
                     <input name="PharmacyName" id="PharmacyName" type="text" value="Walgreens">
                    <label for="PharmacyName">Pharmacy Name: </label>
                   
                </p>
                <div class="clearBlock"></div>
                <span id="pharmacySearchErrMsg" style="color: red;" errmsg="Error: We are unable to identify what address, ZIP code, or Pharmacy Name you are entering. Please enter a new search."></span>
                <div class="PuButtonsArea">
                    <span>Enter a new ZIP code, address, or pharmacy name to change your search.  If you want to change the search radius, use the drop-down menu on the Select Your Pharmacies page.</span><br><br>
                    <a tabindex="0" title="Update" class="linkButtonOrangeNoArrow" id="lnkPharmacySearchUpdate" accesskey="U" type="text/html" alt="Update" object="({'form':'frmPharmacySearch','isGoogleMapDisabled':'false'});"><span>Update</span></a>
                    <span>or <a title="Cancel" class="linkCancel" accesskey="C" onclick="CancelPharmacySearch();return false;" href="" alt="Cancel">Cancel</a></span>
                </div>
    </form>
</fieldset>
</div>

        <a tabindex="0" class="linkButtonGeneric" id="lnkShowHideMap" href="#"><span>Show/Hide Pharmacy Map</span></a>
        <div id="divMyRetailPharmaciesContainer">
            
<div id="divMyRetailPharmacies">

</div> 


        </div>
        
          
        <div class="pharmacySearchNoMap" id="divAdditionalRetailPharmacies" name="divAdditionalRetailPharmacies">
            
<div id="divSearchResultContainer">
<form action="/pfdn/" method="post"><input name="Location" id="Location" type="hidden" value="33173"><input name="VID" id="VID" type="hidden" value="a98QSGvm1WaDvBN8m13/F4vHVe2cjlD9mkBdtkUzV/UpjAV0M32pQ7drEB1Hjdfs4CAQnz1yH0LTjEhCj3TI1A=="><input name="MinLat" id="MinLat" type="hidden" value="25.7000064849854"><input name="MaxLat" id="MaxLat" type="hidden" value="25.7000064849854"><input name="MinLon" id="MinLon" type="hidden" value="-80.3816604614258"><input name="MaxLon" id="MaxLon" type="hidden" value="-80.3816604614258"><input name="RecordCount" id="RecordCount" type="hidden" value="1"><input name="PageNumber" id="PageNumber" type="hidden" value="1">
 </form>
   <!--<div class="srTop"></div>-->
<div class="searchResults">
<div class="srContent">
    <h2>Available Pharmacies</h2>
    <p class="addSelected">Add to Selected Pharmacies</p>
                
                     
                     <div class="pharmacy">
                      <span name="pharmacy" phone="1-305-595-3546" zip="33173" state="FL" city="Miami" address="11690 Sw 72Nd St" pharmacyname="Walgreens" latitude="25.7000064849854" longitude="-80.3816604614258"></span>
                                      
                      
                        <div class="pharmacyAttrContainer">
                            <p>
                            <b>Walgreens</b><br>
                            11690 Sw 72Nd St <br>
                            Miami, FL 33173<br>
                            1-305-595-3546
                            </p>
                            <p> <a href="/pfdn/SharedPharmacy/AddRetailPharmacy?vid=a98QSGvm1WaDvBN8m13%2FF4vHVe2cjlD9mkBdtkUzV%2FUpjAV0M32pQ7drEB1Hjdfs4CAQnz1yH0LTjEhCj3TI1A%3D%3D&amp;pharmacyNABP=1048380&amp;language=English&amp;PlanFinderDRxIntegrationId=bf359df3eaa44466abf162f9fb567ee6831393915806" data-ajax-update="#divMyRetailPharmacies" data-ajax-success="UpdateSearchPharmacyList" data-ajax-mode="replace" data-ajax-method="post" data-ajax="true">Add Pharmacy<span class="HiddenText"> Walgreens</span></a></p>
                                  
                            </div>
                        
                    </div> <!-- class="pharmacy" -->
                    
                    <div class="pagerContainer">
                         
                             
                     </div>
        
                
                <div style="clear: both;"></div>
</div><!-- srContent -->
</div><!--searchResults-->
</div>



        </div> 
        
        <div class="portShadow">
        <form id="frmContinuePlanList" action="https://www.medicare.gov/find-a-plan/results/planresults/summary-of-results.aspx?Language=English" method="post">
            <input name="PlanFinderDRxIntegrationId" id="PlanFinderDRxIntegrationId" type="hidden" value="bf359df3eaa44466abf162f9fb567ee6831393915806">
                                <input name="FontSize" id="FontSize" type="hidden" value="smallFont"><input name="ContractYear" id="ContractYear" type="hidden" value="2016">  
                                
             <a tabindex="0" title="Click to Continue to Plan Results" class="linkButtonOrange" id="btnContinueToPlanResult"><span>Continue to Plan Results</span></a>
        </form>
        <form id="frmBackDrugSearch" action="/pfdn/PlanFinder/DrugSearch" method="post"><input name="PlanFinderDRxIntegrationId" id="PlanFinderDRxIntegrationId" type="hidden" value="bf359df3eaa44466abf162f9fb567ee6831393915806">
                       <input name="FontSize" id="FontSize" type="hidden" value="smallFont"><input name="ContractYear" id="ContractYear" type="hidden" value="2016">
                    </form><form id="frmReloadPage" action="/pfdn/PlanFinder/PharmacySearch" method="post"><input name="PlanFinderDRxIntegrationId" id="PlanFinderDRxIntegrationId" type="hidden" value="bf359df3eaa44466abf162f9fb567ee6831393915806"><input name="Zip" id="Zip" type="hidden" value="33173"><input name="County" id="County" type="hidden" value="12086|MIAMI-DADE"><input name="SearchType" id="SearchType" type="hidden" value="General"><input name="FontSize" id="FontSize" type="hidden" value="smallFont"><input name="Language" id="Language" type="hidden" value="English"><input name="ContractYear" id="ContractYear" type="hidden" value="2016"><input name="ViewType" id="ViewType" type="hidden" value="PUBLIC"><input name="USER_CONFIRMATIONNUMBER" id="USER_CONFIRMATIONNUMBER" type="hidden" value="4923432128"><input name="USER_DATE_YEAR" id="USER_DATE_YEAR" type="hidden" value="2016"><input name="USER_DATE_MONTH" id="USER_DATE_MONTH" type="hidden" value="05"><input name="USER_DATE_DAY" id="USER_DATE_DAY" type="hidden" value="02"><input name="EnrollmentNumber" id="EnrollmentNumber" type="hidden" value="0"><input name="VID" id="VID" type="hidden" value="a98QSGvm1WaDvBN8m13/F4vHVe2cjlD9mkBdtkUzV/UpjAV0M32pQ7drEB1Hjdfs4CAQnz1yH0LTjEhCj3TI1A=="><input name="SubsidyLevel" id="SubsidyLevel" type="hidden" value="4"><input name="SubsidyPercent" id="SubsidyPercent" type="hidden" value="0"><input name="LISCostShare" id="LISCostShare" type="hidden" value="0"><input name="HostName" id="HostName" type="hidden" value="http://www.medicare.gov"><input name="noLISCostShareFlag" id="noLISCostShareFlag" type="hidden" value="False"><input name="CURRENT_COVERAGE" id="CURRENT_COVERAGE" type="hidden" value="Unknown"><input name="CURRENT_SUBSIDY" id="CURRENT_SUBSIDY" type="hidden" value="No Extra Help"><input name="SP_CURRENT_COVERAGE" id="SP_CURRENT_COVERAGE" type="hidden" value="Desconocido"><input name="SP_CURRENT_SUBSIDY" id="SP_CURRENT_SUBSIDY" type="hidden" value="No elegible para subsidio"><input name="IMPORTANT_COVERAGE" id="IMPORTANT_COVERAGE" type="hidden" value="Important Coverage Information"><input name="SP_IMPORTANT_COVERAGE" id="SP_IMPORTANT_COVERAGE" type="hidden" value="Información importante acerca de la cobertura"><input name="CURRENT_SUBSIDY_LINK" id="CURRENT_SUBSIDY_LINK" type="hidden" value="0051"><input name="FUTURE_SUBSIDY_LINK" id="FUTURE_SUBSIDY_LINK" type="hidden" value="0083"><input name="ApplicationType" id="ApplicationType" type="hidden" value="PlanFinder"><input name="IsAllowedToGoPDE" id="IsAllowedToGoPDE" type="hidden" value="False">
            <input name="CSRNotes" id="CSRNotes" type="hidden" value="">
            <input name="Action" id="Action" type="hidden" value="PharmacySearch">
            <input name="TargetRadius" id="TargetRadius" type="hidden" value="0.25" data-val-number="The field TargetRadius must be a number." data-val="true">
            <input name="Location" id="Location" type="hidden" value="33173">
            <input name="GeoCode" id="GeoCode" type="hidden" value="(25.7038331, -80.360297)">
            <input name="PharmacyName" id="PharmacyName" type="hidden" value="Walgreens">
            <input name="ShowMap" type="hidden" value="False">
            <input name="IsPrintMode" type="hidden" value="False">
        </form>
        </div>
    </div><!--portContent-->
    </div><!-- portMainPharmacies -->
    <div id="bottomCorners"></div>
</div>
        </div>
        <div class="BackTopLink"> 
                <a title="Back to Top" class="GoToLink" href="#Top"><img id="ctl00_ctl00_ctl00_topOfPageImage" style="border-width: 0px;" alt="Back to Top" src="https://plancompare.medicare.gov/pfdn/SharedResources/shared/images/back-to-top.png" border="0"></a> 
            </div> 
        <div title="" id="divNoPharmacyInfoModalContainer" style="display: none;">
            <span class="divNoDrugInfoModalTitle">I don’t want to add pharmacies now</span>
            <p id="noPharmacyContent">
                If you do not select a pharmacy, your estimated costs may be significantly higher and may be different than the cost at your pharmacy. Please select a pharmacy <b>to get more accurate estimates</b> of how much your prescription drugs will cost. To select a pharmacy please click “Select Pharmacy”, otherwise click “Skip Pharmacy Selection” to proceed.</p>
            <div class="PuButtonsArea">
                <a tabindex="0" title="Select Pharmacy" class="linkButtonOrangeNoArrow" accesskey="Y" onclick="CloseModalPopUp('divNoPharmacyInfoModalContainer'); return false;" href="#" alt="Select Pharmacy">
                    <span>
                        Select Pharmacy</span></a> <span>
                            or
                            <a tabindex="0" title="Skip Pharmacy Selection" id="lnkAddCancel" accesskey="N" onclick="ValidateVID('a98QSGvm1WaDvBN8m13/F4vHVe2cjlD9mkBdtkUzV/UpjAV0M32pQ7drEB1Hjdfs4CAQnz1yH0LTjEhCj3TI1A==','frmContinuePlanList');" href="#" alt="Skip Pharmacy Selection">
                                Skip Pharmacy Selection</a></span>
            </div>
        </div>
    </div>
Above is the full html. The pharmacy selection page is independent the choice of location and drugs, up to the fact that different pharmacies will be available to choose from, so I do not think that change my selection will have any effect.
Link to comment
Share on other sites

Using that html (wich is not the full html, its imcomplete)  _IELinkClickByText works because it does show the pharmacy name, but in the actual website that information in "hidden" (you can see that in the html). So i have to manage myself to simulate some data to see and test and make sure that there is no other obstacle. Try this code when you reach the part where you have to choose the pharmacys.

#include <IE.au3>

Local $oIE = _IEAttach("", "instance", 2)
If Not IsObj($oIE) Then Exit ConsoleWrite("Error in $oIE" & @CRLF)

Local $oLinks = _IELinkGetCollection($oIE)
If Not IsObj($oLinks) Then Exit ConsoleWrite("Error in $oLinks" & @CRLF)

ConsoleWrite(@extended & " links found" & @CRLF & @CRLF)

Local $aPharmacyNames[3] = ["Barbara M Muina MD PA", "L And J Pharmacy Discount CORP", "Sunset Drugs"]

For $oLink In $oLinks
    $sLink_Text = $oLink.innerTEXT
    $sLink_href = $oLink.href
    ConsoleWrite("$sLink_href: " & $sLink_href & @CRLF)
    ConsoleWrite("$sLink_Text: " & $sLink_Text & @CRLF & @CRLF)
    For $i = 0 To UBound($aPharmacyNames)-1
        If StringInStr($sLink_Text, $aPharmacyNames[$i]) Then _IEAction($oLink, "click")
    Next
Next


Exit

Remeber to change the pharmacy name to ur needs.

Link to comment
Share on other sites

On ‎5‎/‎6‎/‎2016 at 0:24 PM, MichaelHB said:

Using that html (wich is not the full html, its imcomplete)  _IELinkClickByText works because it does show the pharmacy name, but in the actual website that information in "hidden" (you can see that in the html). So i have to manage myself to simulate some data to see and test and make sure that there is no other obstacle. Try this code when you reach the part where you have to choose the pharmacys.

#include <IE.au3>

Local $oIE = _IEAttach("", "instance", 2)
If Not IsObj($oIE) Then Exit ConsoleWrite("Error in $oIE" & @CRLF)

Local $oLinks = _IELinkGetCollection($oIE)
If Not IsObj($oLinks) Then Exit ConsoleWrite("Error in $oLinks" & @CRLF)

ConsoleWrite(@extended & " links found" & @CRLF & @CRLF)

Local $aPharmacyNames[3] = ["Barbara M Muina MD PA", "L And J Pharmacy Discount CORP", "Sunset Drugs"]

For $oLink In $oLinks
    $sLink_Text = $oLink.innerTEXT
    $sLink_href = $oLink.href
    ConsoleWrite("$sLink_href: " & $sLink_href & @CRLF)
    ConsoleWrite("$sLink_Text: " & $sLink_Text & @CRLF & @CRLF)
    For $i = 0 To UBound($aPharmacyNames)-1
        If StringInStr($sLink_Text, $aPharmacyNames[$i]) Then _IEAction($oLink, "click")
    Next
Next


Exit

Remeber to change the pharmacy name to ur needs.

Awesome! Works great. Thanks MichaelHB!

Link to comment
Share on other sites

  • 5 weeks later...

Hi slyx,

You will need to grab the element by class name (pharmacy), then you will need to make a for loop in each element (just like in the code above) get its "innertext", then use an array to store the pharmacys phone number (use StringInStr to check for a match) and here is the change because until now its almost the same process, you will need to grab the "a" tag inside that "div" element where you need to make a click.

This is very important, each time you add or remove a pharmacy this changes the html, so you will need to grab all the elements again and loop through.

Link to comment
Share on other sites

Michael:

Thanks. But now I get new problem, when I try to select pharmacies by radius. Whenever I try to navigate the pages, IE jumps to an empty page.

 

Edited by slyx
Link to comment
Share on other sites

Try:

Local $oForm = _IEGetObjById($oIE, "frmRadius")
Local $oTargetRadius = _IEFormElementGetObjByName($oForm, "TargetRadius")
_IEFormElementOptionSelect($oTargetRadius, 2, 1, "byIndex")

Local $oClassCollection = $oIE.document.getElementsByClassName("pagination")
If Not IsObj($oClassCollection) Then Exit ConsoleWrite("Error in $oClassCollection" & @CRLF)

Local $oClassItem = $oClassCollection.Item(0)
If Not IsObj($oClassItem) Then Exit ConsoleWrite("Error in $oClassItem" & @CRLF)

Local $oTagCollection = $oClassItem.getElementsByTagName("a")
If Not IsObj($oTagCollection) Then Exit ConsoleWrite("Error in $oTagCollection" & @CRLF)

Local $oTagItem = $oTagCollection.Item(1)
If Not IsObj($oTagItem) Then Exit ConsoleWrite("Error in $oTagItem" & @CRLF)

_IEAction($oTagItem, "click")

You can loop through the "_IELinkGetCollection" and grab it by title if you want.

Link to comment
Share on other sites

  • 3 weeks later...

Hi Michael:

I get new problem when I have a drug list ID and then switch to another zipcode. It's the page before adding pharmacies.

 

 

 

DrugListID.jpg

Edited by slyx
Link to comment
Share on other sites

Sure there is slyx. You need to "inspect" the element. In this case you have a ID, just use it. For example to cancel the zip change:

#include <IE.au3>

$oIE = _IEAttach or _IECreate ; * The method that you are using to grab the object *
If Not IsObj($oIE) Then Exit ConsoleWrite("Error in $oIE" & @CRLF)

$oCancelZipChange = _IEGetObjById($oIE, "lnkChangeZipCancel")
If Not IsObj($oCancelZipChange) Or @error Then Exit ConsoleWrite("Error in $oCancelZipChange" & @CRLF)
_IEAction($oCancelZipChange, "click")

Exit

 

Link to comment
Share on other sites

Also a easy one slyx. :)

First one thing that is very important, this is not a "popup" no need to attach, there is no new window (i know its look like, but its not). So lets imagine that after your script input the zip code and navigate to the part when you already have a drug list ID and want to switch to another zipcode you want to confirm if the zip code change event will appear, all you need is after the website is fully loaded to check if the ID's (lnkChangeZipCodelnkChangeZipCancel) exist in the HTML.

$oCancelZipChange = _IEGetObjById($oIE, "lnkChangeZipCancel") ;in this example im just using the cancel button you can do with both or just one
If Not @error then
    ;here it means that the button exists and the "popup" appeared
    ;here what you want to do, click cancel, click change.
EndIf

Remember no need to re-attach, use the current $oIE.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...