I am having a webpage rendered using ExtJS. It renders multiple number of Comboboxes with some generated ID. And each combobox have a different option selected. How can I find out which value is selected in each combo?
While debugging the the HTML DOM I observed that the ExtJS rendering DIV is different and the selectable options are rendered in different DIV at the end. So I am not able to define any XPath to find out the selected value.
Following is the code snippet
<div class="guide-bg" id="sample"><table>
<tr><td id="row1"> </td></tr>
<tr><td id="row2"></td></tr>
</table></div>
<script>
Ext.namespace('Ext.exampledata');
Ext.exampledata.states = [['Alabama'],[ 'Alaska'],['Arizona']];
var store1 = new Ext.data.SimpleStore({
fields: [ 'state'],
data : Ext.exampledata.states
});
var combo1 = new Ext.form.ComboBox({
store: store1, displayField:'state', typeAhead: true,
mode: 'local', forceSelection: true, triggerAction: 'all',
emptyText:'Select...', selectOnFocus:true, renderTo: 'row1'
});
var combo2 = new Ext.form.ComboBox({
store: store1, displayField:'state', typeAhead: true,
mode: 'local', forceSelection: true, triggerAction: 'all',
emptyText:'Select...', selectOnFocus:true, renderTo: 'row2'
});
</script>
After rendering the HTML generated at the 'sample' div is
<div class="guide-bg" id="sample">
<table>
<tbody><tr><td id="row1">
<div class="x-form-field-wrap x-form-field-trigger-wrap" id="ext-gen148" style="width: 206px;">
<input type="text" name="ext-comp-1028" id="ext-comp-1028" autocomplete="off" size="24" class="x-form-text x-form-field x-form-empty-field" style="width: 181px;">
<img class="x-form-trigger x-form-arrow-trigger" src="sp.gif" id="ext-gen149">
</div></td></tr>
<tr><td id="row2">
<div class="x-form-field-wrap x-form-field-trigger-wrap" id="ext-gen150" style="width: 206px;">
<input type="text" name="ext-comp-1029" id="ext-comp-1029" autocomplete="off" size="24" class="x-form-text x-form-field x-form-empty-field" style="width: 181px;">
<img class="x-form-trigger x-form-arrow-trigger" src="sp.gif" id="ext-gen151">
</div></td></tr>
</tbody></table>
</div>
And the options are present independently at the end of the DOM like this
<div class="x-layer x-combo-list " id="ext-gen146" style="position: absolute; z-index: 12005; visibility: hidden;
left: -10000px; top: -10000px; width: 204px; height: 129px; font-size: 12px;">
<div class="x-combo-list-inner" id="ext-gen147" style="width: 204px; height: 129px;">
<div class="x-combo-list-item x-combo-selected">Alabama</div>
<div class="x-combo-list-item">Alaska</div>
<div class="x-combo-list-item">Arizona</div>
</div>
</div>
I cannot just iterate over each x-combo-list-inner
as there is no mapping between the div that renders the combo and the div that holds the available options. If it was just a single combo then it would have been fine, but in my case I have multiple combo boxes with same values.