Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

Handle Keyboard and Mouse Events using Web Driver:-

It is used to handle operation using keyboard events such as key-up,key-down, and mouse events such as mouse-over,mouse-enter,mouse-out, etc.

Selenium Web Driver provide Action class to manage these operations.

Actions ref = new Actions(driver);

Action ref1 = ref.moveToElement('elementname').build()


Example of Keyboard and MouseEvent:-

package contect_us;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;

public class ActionExample {

public static void main(String[] args) {
System.setProperty("Webdriver.chromedriver", "c://chromedriver.exe");
WebDriver driver=new ChromeDriver();
WebElement ele = driver.findElement("email"));
Actions ref = new Actions(driver);
Action ac = ref.moveToElement(ele).click().keyDown(ele,Keys.SHIFT).sendKeys(ele,"abcd").keyUp(ele,Keys.SHIFT).doubleClick(ele).contextClick().build();



Post a Comment

POST Answer of Questions and ASK to Doubt

Previous Post Next Post