如何使用Selenium Webdriver双击元素 [英] How to double click on an element using Selenium Webdriver

查看:1182
本文介绍了如何使用Selenium Webdriver双击元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

This is a dynamic list we have in our site.

这是我要通过双击的HTML标记.

This is the HTML tag where I want to pass double click on.

<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>

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

I want to double click on the first record all the time even though first record gets deleted after each click

推荐答案

由于您要双击第一条记录,因此可以尝试以下Java代码:

Since, you want to double click on the first record, you can try this java code:

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

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();

这篇关于如何使用Selenium Webdriver双击元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆