Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium webdriver Java code using web driver for double click a record in a grid

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();
like image 299
Gokul Avatar asked Feb 20 '14 11:02

Gokul


People also ask

What is required to run a Selenium WebDriver script using Selenium Grid?

Before getting started, download the Selenium Server Standalone package. This package is a jar file, which includes the Hub, WebDriver, and legacy RC that is needed to run the Grid. To get started with Selenium Grid, it is essential to have Java already installed, and set up the environment variables.

How do I run a script using Selenium Grid?

To install Selenium Grid, you only need to download the Selenium Server jar file – the same file used in running Selenium RC tests. To run test scripts on the Grid, you should use the DesiredCapabilities and the RemoteWebDriver objects.

Which action method can be used to double click on an element?

We can perform double click on elements in Selenium with the help of Actions class. In order to perform the double click action we will use moveToElement() method, then use doubleClick() method.


2 Answers

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

This code works!!!

like image 65
Gokul Avatar answered Oct 13 '22 00:10

Gokul


Try this code:

Actions action = new Actions(driver);
WebElement btnElement=driver.findElement("Locator of element"));
action.doubleClick(btnElement).build().perform();
like image 30
iamsankalp89 Avatar answered Oct 12 '22 23:10

iamsankalp89