嗨,我有一個基於ExtJS的用戶界面。我已經知道,在ExtJS中,組合框不是一個真正的組合框,而是輸入文本字段,下拉框圖像和列表的組合。現在我能夠識別控制,但我堅持從列表中選擇值。在HTML源代碼中,我看到列表顯示爲單獨的div,並在我們單擊下拉列表時在源代碼末尾附加。找到下面的下拉控件的HTML源代碼。 {如何在Selenium Webdriver中處理ExtJS的組合框
<div id="ext-gen678" class="x-form-field-wrap x-form-btn-plugin-wrap" style="width: 556px;">
<div id="ext-gen676" class="x-form-field-wrap x-form-field-trigger-wrap x-trigger-wrap-focus" style="width: 521px;">
<input id="ext-gen677" type="hidden" name="GHVOg:#concat#~inputFld~ISGP_UNIV:ft_t_isgp.prnt_iss_grp_oid:0" value="">
<input id="GHVOg:Mixh8:0" class="x-form-text x-form-field gs_dropDown_input gs_req x-form-invalid x-form-focus" type="text" autocomplete="off" size="24" style="width: 504px;">
<img id="trigger-GHVOg:Mixh8:0" class="x-form-trigger x-form-arrow-trigger" alt="" src="../../ext/resources/images/default/s.gif">
}
發現下拉列表中的HTML源代碼如下:
<div id="ext-gen726" class="x-layer x-combo-list x-resizable-pinned" style="position: absolute; z-index: 12007; visibility: visible; left: 294px; top: 370px; width: 554px; height: 123px; font-size: 11px;">
<div id="ext-gen727" class="x-combo-list-inner" style="width: 554px; margin-bottom: 8px; height: 114px;">
<div class="x-combo-list-item"></div>
<div class="x-combo-list-item">12h Universe</div>
<div class="x-combo-list-item">1h Universe</div>
<div class="x-combo-list-item">24h Universe</div>
<div class="x-combo-list-item">2h Universe</div>
<div class="x-combo-list-item x-combo-selected">4h Universe</div>
現在我有問題,從列表中選擇值列表的div元素是不依附於控制。 請同時參閱屏幕截圖,在那裏我有多個類似的控件[命名「添加安全到宇宙」]
在屏幕截圖中可以看到多個下拉菜單[添加安全到宇宙]強調,所有的降名單中出現同樣的價值。所以我怎樣才能從下拉列表中識別這些值。 我想知道ExtJS如何維護下拉div元素與組合框小部件的映射,以便我可以使用相同的邏輯來識別列表。任何人都可以告訴我如何在硒webdriver做這件事?
感謝您的支持!我玩了幾個小時,這解決了我的問題。 – callisto 2014-04-17 07:32:17