Testing 如何使用SeleniumWebDriver双击元素

Testing 如何使用SeleniumWebDriver双击元素,testing,selenium,selenium-webdriver,Testing,Selenium,Selenium Webdriver,这是我们网站上的动态列表 这是我想要双击的HTML标记 <td class="dxgv" align="left" style="color: rgb(51, 51, 51); font-size: 13px; border-bottom: 1px solid rgb(237, 237, 237); border-left-width: 0px; border-right-width: 0px; width: 5.6em; max-width: 6em; text-overflow: e

这是我们网站上的动态列表

这是我想要双击的HTML标记

<td class="dxgv" align="left" style="color: rgb(51, 51, 51); font-size: 13px; border-bottom: 1px solid rgb(237, 237, 237); border-left-width: 0px; border-right-width: 0px; width: 5.6em; max-width: 6em; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;">Sun Kumar</td>
Sun Kumar

我想一直双击第一条记录,即使每次单击后第一条记录都会被删除

,因为要双击第一条记录,可以尝试以下java代码:

(假设网页中有一个表格,因为上面没有完整的HTML代码,内容行以第二行开头。)


我会试试看,让你知道我有疑问。例如,如果我们有“保存”按钮。输入所有详细信息后,如果单击“保存”按钮,我希望验证特定字段数据是否为空。我想用“if”循环实现这一点……有可能吗???当您填写特定字段时,该字段的属性“value”将从null/empty更改为某些数据。因此,您可以使用“getAttribute(“value”)”从字段中获取属性“value”,并检查它是否为null/空,然后您可以继续单击相应的按钮。您知道如何在SeleniumWebDriver中使用if-else循环吗。我尝试使用(if(driver.findElement(By.xpath(“//table//tr[2]//td[@class='dxgv'][1])==null)但是它显示了错误。如何在WebDriver中使用ifelse我建议您在SO中发布一个不同的问题。您将获得所有人的帮助..或者将我添加到聊天中,我们可以从那里继续。实际上,延长此对话并不好,因为它与您发布的问题无关..:)您使用的是哪种编程语言?
Actions act = new Actions(driver);
act.doubleClick(driver.findElement(By.xpath("//table//tr[2]//td[@class='dxgv'][1]"))).build().perform();
 Actions act = new Actions(driver);
 act.moveToElement(driver.findElement(By.xpath("//table//tr[2]//td[@class='dxgv'][1]"))).doubleClick().build().perform();