There are several cases which you can easily solve by using javascriptExecutor. The arguments[0] means the webElement passed in the executeScript command. You can use more than one argument.
When you use only one element:
WebElement webElement0 = driver.findElement(By.xpath("xpath_element_0")); JavascriptExecutor javaScriptExecutor = (JavascriptExecutor)driver; javaScriptExecutor.executeScript("arguments[0].click()", webElement0);
When you use more than one element:
WebElement webElement0 = driver.findElement(By.xpath("xpath_element_0"));
WebElement webElement1 = driver.findElement(By.xpath("xpath_element_1"));
JavascriptExecutor javaScriptExecutor = (JavascriptExecutor)driver; javaScriptExecutor.executeScript("arguments[0].click(); arguments[1].click()", webElement0, webElement1);
This script clicks on 2 element so we have used 2 arguments