Selenium
How to Read/Write Data from Excel File: Selenium POI
File IO is a critical part of any software process. We frequently create a file, open it & update...
Double click action in Selenium web driver can be done using Actions class. Actions class is a predefined class in Selenium web driver used to perform multiple keyboard and mouse operations such as Right Click, Drag and Drop, etc.
Double click in Selenium using Actions class
Actions actions = new Actions(driver); WebElement elementLocator = driver.findElement(By.id("ID")); actions.doubleClick(elementLocator).perform();
Right click action in Selenium web driver can be done using Actions class. Right Click operation is also called Context Click in Selenium. Pre-defined method context click provided by Actions class is used to perform right click operation. Below is the code to demonstrate right click operation using Actions class.
Actions actions = new Actions(driver); WebElement elementLocator = driver.findElement(By.id("ID")); actions.contextClick(elementLocator).perform();
Test Scenario
Code:
package test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.Alert; public class DobuleClickDemo { public static void main(String[] args) throws InterruptedException { WebDriver driver; System.setProperty("webdriver.chrome.driver","X://chromedriver.exe"); driver= new ChromeDriver(); //Launch the Application Under Test (AUT) driver.get("http://demo.guru99.com/test/simple_context_menu.html"); driver.manage().window().maximize(); driver.get("http://demo.guru99.com/test/simple_context_menu.html"); driver.manage().window().maximize(); //Double click the button to launch an alertbox Actions action = new Actions(driver); WebElement link =driver.findElement(By.xpath("//button[text()='Double-Click Me To See Alert']")); action.doubleClick(link).perform(); //Switch to the alert box and click on OK button Alert alert = driver.switchTo().alert(); System.out.println("Alert Text\n" +alert.getText()); alert.accept(); //Closing the driver instance //driver.quit(); } }
Result:
The button labeled "Double-Click Me to See Alert" is clicked and pop-up is shown
In Eclipse, you see the output in the console
Test Scenario:
Code:
package test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.interactions.Actions; public class ContextClick { public static void main(String[] args) throws InterruptedException { WebDriver driver; System.setProperty("webdriver.chrome.driver","X://chromedriver.exe"); driver= new ChromeDriver(); //Launch the Application Under Test (AUT) driver.get("http://demo.guru99.com/test/simple_context_menu.html"); driver.manage().window().maximize(); // Right click the button to launch right click menu options Actions action = new Actions(driver); WebElement link = driver.findElement(By.cssSelector(".context-menu-one")); action.contextClick(link).perform(); // Click on Edit link on the displayed menu options WebElement element = driver.findElement(By.cssSelector(".context-menu-icon-copy")); element.click(); // Accept the alert displayed //driver.switchTo().alert().accept(); // Closing the driver instance //driver.quit(); } }
Result:
Actions action = new Actions(driver); WebElement link = driver.findElement(By.ID ("Element ID")); action.contextClick(link).perform();
Actions action = new Actions(driver); WebElement link = driver.findElement(By.ID ("Element ID")); action. doubleClick (link).perform();
File IO is a critical part of any software process. We frequently create a file, open it & update...
Firefox profile is the collection of settings, customization, add-ons and other personalization...
In this tutorial, we will see how to identify the following form elements Radio Button Check Box...
To understand extensions, lets first understand the three pillars of selenium IDE Action: What...
SoapUI is the most popular open source functional Testing tool for Api Testing . It provides...
What is Jenkins? Jenkins is the leading open-source continuous integration tool developed by...