如何使用Selenium Webdriver双击元素

Sar*_*ana 3 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: ellipsis; overflow: hidden; white-space: nowrap;">Sun Kumar</td>
Run Code Online (Sandbox Code Playgroud)

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

Sub*_*ubh 6

既然,你想双击第一条记录,你可以尝试这个java代码:

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

Actions act = new Actions(driver);
act.doubleClick(driver.findElement(By.xpath("//table//tr[2]//td[@class='dxgv'][1]"))).build().perform();
Run Code Online (Sandbox Code Playgroud)

要么

 Actions act = new Actions(driver);
 act.moveToElement(driver.findElement(By.xpath("//table//tr[2]//td[@class='dxgv'][1]"))).doubleClick().build().perform();
Run Code Online (Sandbox Code Playgroud)