2011-07-21 3 views
1

これは、セレニウムを使ってdijitによって書かれたコンボボックスをクリックしてリストから項目を選択する簡単な方法ですか?セレニウム取扱コンボボックスの記録/使用方法とdijitで使用するアイテムの選択方法は?

ソース:

<div id="widget_ofertaForm_offerElements_1_" class="dijit dijitReset dijitInlineTable dijitLeft AreaStd dijitComboBox" tabindex="-1" wairole="combobox" dojoattachpoint="comboNode" dojoattachevent="onmouseenter:_onMouse,onmouseleave:_onMouse,onmousedown:_onMouse" role="combobox" style="width: 420px;" widgetid="ofertaForm_offerElements_1_"> 
<div style="overflow: hidden;"> 
<div class="dijitReset dijitRight dijitButtonNode dijitArrowButton dijitDownArrowButton" dojoattachevent="onmousedown:_onArrowMouseDown,onmouseup:_onMouse,onmouseenter:_onMouse,onmouseleave:_onMouse" wairole="presentation" dojoattachpoint="downArrowNode" role="presentation"> 
<div class="dijitArrowButtonInner">&thinsp;</div> 
<div class="dijitArrowButtonChar">ˇ</div> 
</div> 
<div class="dijitReset dijitValidationIcon"> 
<br> 
</div> 
<div class="dijitReset dijitValidationIconText">?</div> 
<div class="dijitReset dijitInputField"> 
<input id="ofertaForm_offerElements_1_" class="dijitReset" type="text" waistate="haspopup-true,autocomplete-list" wairole="textbox" dojoattachpoint="textbox,focusNode" dojoattachevent="onkeypress:_onKeyPress,compositionend" autocomplete="off" role="textbox" aria-haspopup="true" aria-autocomplete="list" aria-invalid="false" tabindex="0" aria-required="true" value="HTC TOUCH DUAL CZARNY - 1382.95 PLN 16 szt. (1701.03 PLN Z VAT) A (+01101100)"> 
<input type="hidden" name="offerElements[1]" value="#_01101100#MATERIAL_BONUS"> 
</div> 

私はここにすべての項目がないことを知っているが、私はコンボボックスをクリックしたとき、彼らは本当に自分自身を示しています。

私はセレンIDEを使用しようとしました。だから私は書いた:

 selenium.clickAt("class=dijitArrowButtonInner","100"); 

それは働いた。しかし、セレンIDEのためにのみ、junitで作業中に私はメッセージ "要素が見つかりませんでした"を得ました。

ご協力いただきますようお願い申し上げます。
ps。私の英語/タイトルが正しくない場合はそれを修正してください。ごめんなさい。

答えて

2

このようなコンボボックスからいくつかのアイテムを選択する場合は、選択する要素(たとえば、id、クラス、その他の属性)を知っている必要があります。その後、あなたが次に選択コントロールで

selenium.click("div.dijitArrowButtonChar"); 

をクリックする必要があり、あなたがショーを選択する必要がある要素まで、待つ必要があります。

selenium.waitForCondition("selenium.isElementPresent(\""+selector_for_element+"\")", "1000"); 

ここで、「selector_for_element」は選択する要素のセレクタです。 「div.selectItem:last()」と同様です。

要素はショーの後、あなたはそれをクリックする必要があります。

selenium.click(selector_for_element); 

コードセレン1.0のために。

+0

ありがとうございました。 – deadfish

関連する問題