How to write selenium java code for doubleClick()
on a record using web driver?
I have displayed some records in the body part. Once I clicked on a record we should get a popup window to update it.
Please suggest how to write Selenium Java code using web driver.
I have tried following code:
Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.xpath("//table/tbody/tr[2]/td/div/div/table/tbody/tr[10]/td[1]"))).doubleClick().build().perform();
Try this code:
This code works!!!
And in case if have no additional actions binded to singleclick, you can use:
Actually, it should works in most cases (except you have some custom system doubleclick settings)
You should use the
Actions()
class as this includes a 'double-click' action.Use Actions class to perform mouse, keyboard actions on WebElements using WebDriver.
I implemented Ran's (immediately above my post) solution. I'm writing Java in Eclipse and using Selenium WebDriver.
There are 2 imports that you'll need:
Then, I implemented the code thusly:
Thanks to Ran! I'd been struggling with this one for several hours. Invoking the single click twice doesn't work for me - too much time between the events to be captured by the browser under test as a double-click.