<div id="member_sel_div" style="">
<table class="dataTable" width="100%" cellspacing="0" cellpadding="0" border="0" summary="">
<tbody>
<tr class="heding">
<tr class="odd">
<td valign="top" width="4%">
<input id="mgrp_-1" class="reset" type="checkbox" onclick="showMembers(-1, 0)" value="-1" name="member_group_id[]" style="position: absolute; z-index: -1; visibility: hidden;"/>
<span class="jquery-checkbox jquery-checkbox-checked" style="-moz-user-select: none;">
<span class="mark jquery-checkbox-hover">
<img width="24" height="24" src="/purebenefits/dev/images/empty.png"/>
</span>
</span>
</td>
<td valign="top" style="padding-left:0;">NO GROUP</td>
</tr>
我工作的一個測試情況不止一個複選框將出現,並onclicking每個複選框它會調用一個函數showMembers(複選框值,0)onclick事件使用fireevent()函數沒有在硒IDE工作
在我的測試案例中,我首先計算了複選框的數量,然後使用循環,我也可以點擊每個複選框,但點擊複選框的onclick函數並沒有解除爲什麼我無法繼續。我已經使用fireevent功能還,但結果是一樣
我使用硒IDE,該部分的HTML代碼上面給出我對硒的IDE編寫的代碼如下
<tr>
<td>assertTextPresent</td>
<td>New Quote</td>
<td></td>
</tr>
<tr>
<td>select</td>
<td>name=insurance_type_id</td>
<td>label=Group Life Assurance</td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>Policy Features </td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Bronze</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@id='product_list_div']/table[@class='priceTable']/tbody/tr/th[4]/label/input[@id='prodid_6']</td>
<td></td>
</tr>
<tr>
<td>storeXpathCount</td>
<td>//div[@id='member_sel_div']/table[@class='dataTable']/tbody/tr[@class='odd']/td/input[@type='checkbox']/</td>
<td>count</td>
</tr>
<tr>
<td>echo</td>
<td>${count}</td>
<td></td>
</tr>
<tr>
<td>getEval</td>
<td>alert("Number of Group : ${count}")</td>
<td></td>
</tr>
<tr>
<td>store</td>
<td>1</td>
<td>j</td>
</tr>
<tr>
<td>store</td>
<td>1</td>
<td>i</td>
</tr>
<tr>
<td>store</td>
<td>javascript{storedVars.count;}</td>
<td></td>
</tr>
<tr>
<td>while</td>
<td>storedVars.i<=${count}</td>
<td></td>
</tr>
<tr>
<td>echo</td>
<td>${i}</td>
<td></td>
</tr>
<tr>
<td>echo</td>
<td>${j}</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>${i}-${j}</td>
<td>k</td>
</tr>
<tr>
<td>storeEval</td>
<td>window.document.getElementsByName('member_group_id[]')[${k}].value</td>
<td>abc</td>
</tr>
<tr>
<td>echo</td>
<td>${abc}</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@id='member_sel_div']/table[@class='dataTable']/tbody/tr[@class='odd']/td/input[@value='${abc}']/</td>
<td></td>
</tr>
<tr>
<td>fireEvent</td>
<td>//div[@id='member_sel_div']/table[@class='dataTable']/tbody/tr[@class='odd']/td/input[@value='${abc}']</td>
<td>"click"</td>
</tr>
<tr>
<td>store</td>
<td>javascript{storedVars.i++;}</td>
<td></td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
嘗試'clickAt',而是如果'click'和'fireEvent' –
@Aleh Douhi 根據你的建議,我試圖clickAt,而是如果點擊fireEvent,但onclick事件在不觸發。 – John
那裏有一個單選按鈕,onclick事件正確觸發,但當涉及複選框onclick事件不會觸發 – John