我正在为 GWT 应用程序编写自动测试。我尝试双击表格元素。我正在使用此代码单击:
browser.element(:xpath, '/html/body/div[5]/div[2]/div/div/div/div[2]/div/div/div/div/div/div/div/div[2]/div/div[2]/div/div/table/tbody[2]/tr[1]/td[1]/div').double_click
执行此命令时,我收到如下错误:
Cannot perform native interaction: Could not load native events component
我已将此代码添加到我的脚本中,但这没有帮助:\
profile = Selenium::WebDriver::Firefox::Profile.new
profile.native_events = true
browser = Watir::Browser.new :firefox, :profile => profile
它是我尝试单击的 html 的一部分:
<tbody>
<tr aria-posinset="0" aria-setsize="11" role="listitem">
<td class="cellSelected" height="22" align="left" style="padding-top: 0px; padding-bottom: 0px; width: 100px; overflow: hidden;">
<div style="overflow:hidden;WIDTH:96px;" cellclipdiv="true" role="presentation">
<nobr>2004</nobr>
</div>
</td>
<td class="cellSelected" height="22" align="left" style="padding-top: 0px; padding-bottom: 0px; width: 371px; overflow: hidden;">
<div style="overflow:hidden;WIDTH:367px;" cellclipdiv="true" role="presentation">
</td>
<td class="cellSelected" height="22" align="right" style="padding-top: 0px; padding-bottom: 0px; width: 200px; overflow: hidden;">
<td class="cellSelected" height="22" align="left" style="padding-top: 0px; padding-bottom: 0px; width: 372px; overflow: hidden;">
</tr>
<tr aria-posinset="1" aria-setsize="11" role="listitem">
<tr aria-posinset="2" aria-setsize="11" role="listitem">
<tr aria-posinset="3" aria-setsize="11" role="listitem">
<tr aria-posinset="4" aria-setsize="11" role="listitem">
<tr aria-posinset="5" aria-setsize="11" role="listitem">
<tr aria-posinset="6" aria-setsize="11" role="listitem">
<tr aria-posinset="7" aria-setsize="11" role="listitem">
<tr aria-posinset="8" aria-setsize="11" role="listitem">
<tr aria-posinset="9" aria-setsize="11" role="listitem">
<tr aria-posinset="10" aria-setsize="11" role="listitem">
</tbody>
我知道 xpath 不是很好,但它可以工作。例如常规点击工作正常。
我使用 selenium 2.31、ruby 1.9.3 和 firefox 17。
这是 div 和 table。谢谢
<div id="isc_K7" style="POSITION:relative;VISIBILITY:inherit;Z-INDEX:206084;CURSOR:default;" eventproxy="isc_PolicyListGrid_1_body">
<div style="position:relative;z-index:1000;">
<div id="isc_PolicyListGrid_1_body$47a" style="width:1px;height:0px;overflow:hidden;display:none;">
<img width="1" height="0" border="0" align="TEXTTOP" suppress="TRUE" src="blank.gif">
</div>
<table id="isc_K7table" class="listTable" width="1043" cellspacing="0" cellpadding="2" border="0" style="table-layout:fixed;overflow:hidden;wrap:false;padding-left:0px;padding-right:0px;" role="presentation">
<tbody></tbody>
<colgroup>
<tbody>
</table>
<div id="isc_PolicyListGrid_1_body$47t" style="width:1px;height:0px;overflow:hidden;display:none;">
</div>
<table style="position:absolute;top:0px;font-size:1px;height:100%;width:100%;z-index:1;overflow:hidden;visibility:hidden;">
</div>