我有一个场景,我需要使用selenium webdriver在ext-js应用程序中的网格中选择一行。基于行选择启用了一些按钮。 html片段如下所示
<div id="ext-element-55" class="x-grid-item-container" style="width: 756px; transform: translate3d(0px, 0px, 0px);" role="presentation">
<table id="tableview-1812-record-288" class="x-grid-item x-grid-item-selected" cellspacing="0" cellpadding="0" style=";width:0" data-recordindex="0" data-recordid="288" data-boundview="tableview-1812" role="presentation">
<tbody>
<tr class=" x-grid-row" role="row" aria-selected="true">
<td class="x-grid-cell x-grid-td x-grid-cell-gridcolumn-1825 x-grid-cell-first x-unselectable" data-columnid="gridcolumn-1825" tabindex="-1" role="gridcell" style="width: 378px;">
<div class="x-grid-cell-inner " style="text-align:1;" unselectable="on">FirstElementToSelect</div>
</td>
<td class="x-grid-cell x-grid-td x-grid-cell-gridcolumn-1826 x-grid-cell-last x-unselectable" data-columnid="gridcolumn-1826" tabindex="-1" role="gridcell" style="width: 378px;">
<div class="x-grid-cell-inner " style="text-align:1;" unselectable="on">
</td>
</tr>
</tbody>
</table>
<table id="tableview-1812-record-289" class="x-grid-item x-grid-item-alt" cellspacing="0" cellpadding="0" style=";width:0" data-recordindex="1" data-recordid="289" data-boundview="tableview-1812" role="presentation">
<tbody>
<tr class=" x-grid-row" role="row" aria-selected="true">
<td class="x-grid-cell x-grid-td x-grid-cell-gridcolumn-1825 x-grid-cell-first x-unselectable" data-columnid="gridcolumn-1825" tabindex="-1" role="gridcell" style="width: 378px;">
<div class="x-grid-cell-inner " style="text-align:1;" unselectable="on">SecondElementToSelect</div>
</td>
<td class="x-grid-cell x-grid-td x-grid-cell-gridcolumn-1826 x-grid-cell-last x-unselectable" data-columnid="gridcolumn-1826" tabindex="-1" role="gridcell" style="width: 378px;">
<div class="x-grid-cell-inner " style="text-align:1;" unselectable="on">
</td>
</tr>
</tbody>
</table>
</div>
WebElement单击(在div / tr / td / table上尝试 - 所有元素)适用于Chrome和FF并选择行但不为IE选择行。还尝试了动作类,机器人API,但这些也不适用于IE。 有没有办法让它在IE中使用本机事件(除了使用javascript选择)。请注意,在使用requiredWindowFocus时,它确实可以在IE中工作,但我不想使用它,因为它有局限性 并行工作在同一台机器上并在远程锁定机器上运行测试。
Selenium版本 - 2.53.0 浏览器 - IE11 IE驱动程序版本3.0
答案 0 :(得分:0)
请分享更多详情,如IE版,Selenium版。
请注意,在IE 9,10和11中已经报告了Click事件的一些问题。查找更多here。
答案 1 :(得分:0)
从IE 9开始,这个点击问题似乎仍在继续。Check here。
但是,请尝试这些方法。现在可能是一种解决方法。
更改driver capabilities
。
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability("nativeEvents",false);
capabilities.setCapability("ignoreZoomSetting", true);
WebDriver driver = new InternetExplorerDriver(capabilities);
试试javascript click
。请查看此post。
keys.ENTER
。 Official docs。driver.findElement("path")).sendKeys(KEYS.ENTER);
希望这有帮助。