Currently, I am facing a situation where my webpage is being rendered using ExtJS. It renders multiple Comboboxes each with a unique generated ID and a different option selected in each one. I want to be able to determine which value is selected in each combo box.
During my debugging process of the HTML DOM, I noticed that the ExtJS rendering DIV is distinct from the DIV in which the selectable options are rendered at the end. This makes it challenging for me to define any XPath to identify the selected values.
Here is a snippet of the code:
<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>
Upon rendering, the HTML generated within the 'sample' div looks like this:
<div class="guide-bg" id="sample">
< table>
<tbody>< tr>< td id="r ow1">
<div class="x-form-field-wrap x-form -field-trigger-wrap" id="ext-gen148" style="width: 206px ;"& gt;
<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: 181 px;"& gt;
<img class= "x-form-trigger x-form-arrow-tri gger "src="sp.gif "id="ext-gen149 "& gt;
< /div>& lt; /td> & nt; /tr> & lt; tr> & lt; td id="ro w2">
< div class="x-form-field-wrap x-form-fie ld-trigger-wrap" id="ext-gen150" style="w idth: 206px;"> < input type=" text" n ame="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 "\"> & quot; ;
& lt;im cc lass ="x -form-trigger x -form-arrow-trigger "scr c="sp.gif "id="ext-gen151 ">
& lt; /div>& lt; /td > & nt; /tr> & lt; tbody>& lt; /table> & lt; /div>
The available options are listed independently at the end of the DOM as shown below:
& lt;div class="x-layer x-c ombolist" id="ext-gen146"style="position:abs olute; z-index:12005;visibility:hidden;left :-10000px; top:-10000px;width:204px;height:129px;font-size:12px;">
& lt;div clas s="x-combo-list-inner"id="ext-gen147"style="widt h : 204px;height:129px; ">
& lt;div cla ss="x-combo-list-item x-combo-selected "> Alabama</div>
& lt;div cl ass= "x-combo-list-item "> Alaska</div >
& lt; div class="x-combo-list-item"> Arizona</di v>
</div>
< /div>
< /div>
In my scenario, simply iterating over each x-combo-list-inner
element is not feasible because there is no clear mapping between the div containing the combo box and the div holding the available options. While dealing with multiple combo boxes having the same values, this lack of distinction poses a challenge.