Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
802 views
in Technique[技术] by (71.8m points)

javascript - VBA Web Automation Select Drop Down Value From HTML Drop Down

I am trying to automate the selection from a drop down list in html via VBA.

HTML is below. I can set the index of the option and also change the value of the combobox, but neither is actually sticking and changing the value in the combobox.

I have tried:

'this return "Object Not Supported" Error.
doc.getElementById("CoPolicyCreateSelectHTML_DynamicStore_PolSearchCriteria_LST_comboboxinput").selectedIndex = 1

'The below does enter the term I want, but clicking the search button resets it to the first item in the list.
doc.getElementById("CoPolicyCreateSelectHTML_DynamicStore_PolSearchCriteria_LST_comboboxinput").Value = "Quote Number"

'this sets the index but does not update the actual combobox
doc.getElementById("CoPolicyCreateSelectHTML_DynamicStore_PolSearchCriteria_LST").selectedIndex = 2

'and fire events doesn't help either
doc.getElementById("CoPolicyCreateSelectHTML_DynamicStore_PolSearchCriteria_LST").fireEvent "onChange" (or "onClick")

<span class="input-large dynamic-input" id="CoPolicyCreateSelectHTML_DynamicStore_PolSearchCriteria" data-bind="bizEntityDynamic: DynamicStore.PolSearchCriteria" data-sid="CoPolicyCreateSelectHTML_DynamicStore_PolSearchCriteria_46" data-origin="bizEntityDynamic">
   <select class="input-large dynamic-input combobox" id="CoPolicyCreateSelectHTML_DynamicStore_PolSearchCriteria_LST" style="display: none;" data-bind="bizEntityList: DynamicStore.PolSearchCriteria" data-sid="CoPolicyCreateSelectHTML_DynamicStore_PolSearchCriteria_LST_47" data-origin="bizEntityDynamic" data-origid="CoPolicyCreateSelectHTML_DynamicStore_PolSearchCriteria" data-origclass="input-large dynamic-input">
  <option value=""></option>
  <option value="1">Name&nbsp;of&nbsp;Insured</option>
  <option value="2">Quote&nbsp;Number</option>
  <option value="4">Account&nbsp;Number</option>
  <option value="8">Policy&nbsp;Number</option>
  <option value="8388608">Policy&nbsp;Prefix&nbsp;/&nbsp;Number</option>
  <option value="16">User&nbsp;Id</option>
  <option value="4194304">Underwriter&nbsp;Id</option>
  <option value="32">Sys.&nbsp;Assign&nbsp;Number</option>
  <option value="524288">Prev&nbsp;Sys.&nbsp;Assign&nbsp;Number</option>
   </select>
   <span class="custom-combobox-large" id="CoPolicyCreateSelectHTML_DynamicStore_PolSearchCriteria_LST_comboboxwrapper">
<span class="ui-helper-hidden-accessible" role="status" aria-live="polite"></span>
<input title="Select search criteria" class="custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left ui-autocomplete-input f1HelpTarget" id="CoPolicyCreateSelectHTML_DynamicStore_PolSearchCriteria_LST_comboboxinput" type="text" data-cbox="closed" autocomplete="off" data-dropdown="true" data-origval="Name&nbsp;of&nbsp;Insured">
<a tabindex="-1" title="" class="ui-button ui-widget ui-state-default ui-button-icon-only custom-combobox-toggle ui-corner-right" role="button" aria-disabled="false">
<span class="ui-button-icon-primary ui-icon ui-icon-triangle-1-s"></span>
<span class="ui-button-text"></span></a>
</span>
</span>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...