我正在使用 Selenium 网络驱动程序并尝试单击搜索图像,但无法单击它。我不确定出了什么问题。我努力了
xpath 选项
driver.findElement(By.xpath("//form/div/div/div/div/div[2]/table/tbody/tr/td[2][@class='icon-button combo-button']")).click();
还尝试了图像
driver.findElement(By.xpath("//form/div/div/div/div/div[2]/table/tbody/tr/td[2]/img[contains(@src,'iconActionSearch.png')]")).click();
我已经从 Selenium IDE 尝试过完全相同的方法
driver.findElement(By.xpath("//div[@id='divToolbar']/div[2]/table/tbody/tr/td[2]/img")).click();
这是上面的代码应该起作用的地方
<td class="icon-button combo-button" title="Search">
<img src="../common/images/iconActionSearch.png">
这是我的 html 片段
<!DOCTYPE html>
<html>
<head>
<body class="navigator" onbeforeunload="closeAllChildWindows()" onload="initializeSlideIns()">
<div class="mmenu" style="display: none;">
<div class="mmenu" style="display: none;">
<div class="mmenu" style="display: none;">
<div class="mmenu" style="display: none;">
<div class="mmenu" style="display: none;">
<div class="mmenu" style="display: none;">
<div class="mmenu" style="display: none;">
<div class="mmenu" style="display: none;">
<div class="mmenu" style="display: none;">
<div class="mmenu" style="display: none;">
<div class="mmenu" style="display: none;">
<div class="mmenu" style="display: none;">
<div class="mmenu" style="display: none;">
<div class="mmenu" style="display: none;">
<div class="mmenu" style="display: none;">
<form name="navigatorForm">
<div id="pageHeadDiv">
<div class="toolbars">
<div class="toolbar-container">
<div id="divToolbar" class="toolbar-frame">
<div class="toolbar">
<div class="toolbar functions">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="icon-button" nowrap="" itemid="emx567127522162.935" title="Home">
<td class="icon-button combo-button" title="Search">
<img src="../common/images/iconActionSearch.png">
</td>
<td class="menu-arrow" title="Search">
<td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="breadcrumbs">
<script src="./scripts/emxBreadcrumbs.js" type="text/javascript">
<script src="./scripts/emxQuery.js" type="text/javascript">
<script type="text/javascript">
<div id="pageContentDiv" style="top: 62px;">
<div id="layerOverlay" style="display: none;"></div>
<div id="panelSlideIn" class="dialog viewer" style="top: 62px; display: none;">
<div id="windowshadeMask" style="z-index: 50; display: none;">
</form>
<div id="checkoutdiv">
</body>
</html>