D-man

Select a web form drop down non interactively

1 post in this topic

Greetings,

I have an interesting challenge for automating a web form submission, which generates a report and presents an option to open or save the generated XML file. The automation needs to occur non-interactively while the Windows PC is locked.

Report generation flow:

1.    Login to website
2.    Navigate to the report page where the form must be submitted. (Web page source code excerpt is at the bottom of the post)
3.    Select the customer via a drop down menu. This in turn populates the select form called 'PIR' with two values. I think this is done with an AJAX call.
4.    Select one of the two numeric values in the 'PIR' select form box.
5.    Select Output Option of Excel. 
6.    Click the submit button.
7.    The IE browser prompts to Save or Open the file. Choose save.

I am stuck at step 3. The customer value does get selected in the drop down list, but it doesn't kick of the AJAX call, which in turn would populate the next required select form, called 'PIR', with two values. Interactively, AJAX call happens when using the mouse or the keyboard down arrow to select the customer. Unfortunately, this doesn't work using the 'Send' function because the PC is locked. 

Could some one please let me know what my options are to surpass this obstacle? Any help is greatly appreciated.

 

Auto IT Code:

Local $oIE = _IECreate("https://mysite.com/login.jsp")
Local $oForm = _IEFormGetCollection($oIE, 0)
Local $oQueryUserID = _IEFormElementGetObjByName($oForm, "USERID")
Local $oQueryPassword = _IEFormElementGetObjByName($oForm, "PASSWORD")
_IEFormElementSetValue($oQueryUserID, "MyUser")
Sleep(500)
_IEFormElementSetValue($oQueryPassword, "MyPassword")
Sleep(500)
_IEFormSubmit($oForm, 0)
_IELoadWait($oIE)
_IENavigate($oIE, "http://report.site.com/")
_IELoadWait($oIE)
_IENavigate($oIE, "http://report.site.com/reports/configure?report=some_reports/customer/")
_IELoadWait($oIE)

Local $oForm2 = _IEFormGetCollection($oIE, 0)
Local $oQueryCustomer = _IEFormElementGetObjByName($oForm2, "customer")
_IEFormElementOptionSelect($oQueryCustomer, "CustomerName1", 1, "byValue", 1)
_IEFormElementSetValue($oQueryCustomer, "CustomerName1")

;~ Tried some things below, but they didn't help kick off AJAX call...
;~ _IEAction($oQueryCustomer, "click")
;~ _IEAction($oQueryCustomer, "enable")
;~ _IEAction($oQueryCustomer, "unselect")
;~ _IEFormElementOptionSelect($oQueryCustomer, "CSX", 1, "byValue", 1)
;~ _IEAction($oQueryCustomer, "focus")
;~ Send("{DOWN}")


;~ Tried setting the value without AJAX call, but it didn't work...
sleep(1000)
Local $oQueryPIR = _IEFormElementGetObjByName($oForm2, "pir[]")
_IEFormElementOptionSelect($oQueryPIR, "142297", 1, "byValue", 1)


sleep(1000)
Local $oQueryOutputFile = _IEFormElementGetObjByName($oForm2, "exports")
_IEFormElementOptionSelect($oQueryOutputFile, "Excel")

Local $oSubmit = _IEGetObjByName($oIE, "op")
_IEAction($oSubmit, "click")

 

HTML Page Source Excerpt:

<script type="text/javascript" src="https://report.site.com/sites/default/files/js/js_0gj6QcpfRH2jzTbCQqf7kEkm4MXY0UA_sRhwPc8jC1o.js"></script>
<script type="text/javascript" src="https://report.site.com/sites/default/files/js/js_amhesePqDck6Ny-KEBHv3KTsIIwYaH-X60Bgmb2npQA.js"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
      // close script tag for SecKit protection
      //--><!]]>
      </script>
      <script type="text/javascript" src="/sites/all/modules/seckit/js/seckit.document_write.js"></script>
      <link type="text/css" rel="stylesheet" id="seckit-clickjacking-no-body" media="all" href="/sites/all/modules/seckit/css/seckit.no_body.css" />
      <!-- stop SecKit protection -->
      <noscript>
      <link type="text/css" rel="stylesheet" id="seckit-clickjacking-noscript-tag" media="all" href="/sites/all/modules/seckit/css/seckit.noscript_tag.css" />
      <div id="seckit-noscript-tag">
        <h1>Sorry, you need to enable JavaScript to visit this website.</h1>
      </div>
      </noscript>
      <script type="text/javascript">
      <!--//--><![CDATA[//><!--
      // open script tag to avoid syntax errors
//--><!]]>
</script>
<script type="text/javascript" src="https://report.site.com/sites/default/files/js/js_UCU3cKT-4rkP4kMVVQYWSxLoL4Tlr7sFEouG_B2zEmY.js"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery.extend(Drupal.settings, {"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"bartik","theme_token":"DWNeH370YcViwKUVhXE0AOL0BdH54ooaMSP0xxP5Efk","jquery_version":"1.7","js":{"sites\/all\/modules\/jquery_update\/replace\/jquery\/1.7\/jquery.min.js":1,"misc\/jquery.once.js":1,"misc\/drupal.js":1,"sites\/all\/modules\/jquery_update\/replace\/ui\/external\/jquery.cookie.js":1,"sites\/all\/modules\/jquery_update\/replace\/misc\/jquery.form.min.js":1,"misc\/ajax.js":1,"sites\/all\/modules\/jquery_update\/js\/jquery_update.js":1,"0":1,"sites\/all\/modules\/clock\/clock.js":1,"misc\/progress.js":1},"css":{"modules\/system\/system.base.css":1,"modules\/system\/system.menus.css":1,"modules\/system\/system.messages.css":1,"modules\/system\/system.theme.css":1,"modules\/comment\/comment.css":1,"sites\/all\/modules\/date\/date_api\/date.css":1,"sites\/all\/modules\/date\/date_popup\/themes\/datepicker.1.7.css":1,"modules\/field\/theme\/field.css":1,"modules\/node\/node.css":1,"modules\/user\/user.css":1,"sites\/all\/modules\/ssg_shipping\/css\/ssg_shipping.css":1,"themes\/bartik\/css\/layout.css":1,"themes\/bartik\/css\/style.css":1,"themes\/bartik\/css\/colors.css":1,"themes\/bartik\/css\/print.css":1,"themes\/bartik\/css\/ie.css":1,"themes\/bartik\/css\/ie6.css":1}},"clock":{"names":["clock-date-1","clock-date-2","clock-date-3","clock-date-4","clock-date-5"],"clocks":{"clock-date-1":{"time_zone":"UTC","date_format":"m-d-Y H:i:s T","local":false,"offset_name":"UTC","offset_seconds":"0","daylight_savings_time":"0"},"clock-date-2":{"time_zone":"America\/New_York","date_format":"m-d-Y H:i:s T","local":false,"offset_name":"EST","offset_seconds":"-18000","daylight_savings_time":"0"},"clock-date-3":{"time_zone":"America\/Chicago","date_format":"m-d-Y H:i:s T","local":false,"offset_name":"CST","offset_seconds":"-21600","daylight_savings_time":"0"},"clock-date-4":{"time_zone":"America\/Los_Angeles","date_format":"m-d-Y H:i:s T","local":false,"offset_name":"PST","offset_seconds":"-28800","daylight_savings_time":"0"},"clock-date-5":{"time_zone":"Pacific\/Honolulu","date_format":"m-d-Y H:i:s T","local":false,"offset_name":"HST","offset_seconds":"-36000","daylight_savings_time":"0"}}},"ajax":{"edit-customer":{"callback":"pmtool_customer_ajax_pir","wrapper":"pir-div","method":"replaceWith","effect":"fade","event":"change","url":"\/system\/ajax","submit":{"_triggering_element_name":"customer"}}}});
//--><!]]>
</script>
......
(My comments: Excluded some non pertinent code)
......
</div>
  </div>
      </div></div> <!-- /.section, /#sidebar-first -->
    
    <div id="content" class="column"><div class="section">
            <a id="main-content"></a>
                    <h1 class="title" id="page-title">
          Configure Tool Customer Report        </h1>
                          <div class="tabs">
                  </div>
                          <div class="region region-content">
    <div id="block-system-main" class="block block-system">

    
  <div class="content">
    <form action="/reports/configure?report=some_reports/customer" method="post" id="pmtool-customer" accept-charset="UTF-8"><div><div class="form-item form-type-select form-item-customer">
  <label for="edit-customer">Customer <span class="form-required" title="This field is required.">*</span></label>
 <select id="edit-customer" name="customer" class="form-select required"><option value="" selected="selected">- Select -</option><option value="CustomerName1">CustomerName1</option><option value="CustomerName2">CustomerName2.....etc ...... </select>
</div>
<div id='pir-div'><div class="form-item form-type-select form-item-pir">
  <label for="edit-pir">PIR <span class="form-required" title="This field is required.">*</span></label>
 
 (My comments: Line below is the source for select form PIR before the customer is selected from the drop down menu in the code above)
 <select multiple="multiple" name="pir[]" id="edit-pir" class="form-select required"></select>
 
 (My comments: Line below is the source for select form PIR after the customer is selected from the drop down menu in the code above and AJAX call is made)
 <select multiple="multiple" name="pir[]" id="edit-pir--2" class="form-select required"><option value="142297">142297</option><option value="3488209">3488209</option></select>

</div>
</div><input type="hidden" name="form_build_id" value="form-tdUyE1IxJxS3p55KBxqOge1u9dozu6xtFBAum51kO9I" />
<input type="hidden" name="form_token" value="g4zpW8cKi8GRf4nzoPZpG08qUdotnOhLdQrfBxkoTSc" />
<input type="hidden" name="form_id" value="pmtool_customer" />
<div class="form-item form-type-select form-item-exports">
  <label for="edit-exports">Output Option <span class="form-required" title="This field is required.">*</span></label>
 <select id="edit-exports" name="exports" class="form-select required"><option value="HTML" selected="selected">HTML</option><option value="Excel">Excel</option></select>
</div>
<input type="submit" id="edit-submit" name="op" value="Submit" class="form-submit" /></div></form>  </div>
</div>
  </div>

 

Share this post


Link to post
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