<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>
我正在研究一个测试用例,其中会出现多个复选框,并且点击每个复选框,它将调用一个函数showMembers(复选框值,0)
在我的测试用例中,我首先计算了复选框的数量,然后使用循环我也可以单击每个复选框,但是点击复选框时它的onclick函数没有解雇为什么我无法继续。我也使用了fireevent功能但效果相同
我正在使用selenium IDE,该部分的html代码如上所示,我为selenium 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>
答案 0 :(得分:0)
在应用fireEvent之前,您是否尝试过关注该元素?可能就是这种情况。