In this video, we will see Selenium Mouse Actions Hover, Click, Double Click, Right Click | Mouse Actions in Selenium Webdriver
Program Code:
import java.time.Duration;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
public class MouseActions {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\selenium\\chromedriver_win32\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://amazon.in");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
Actions a=new Actions(driver);
a.moveToElement(driver.findElement(By.xpath("//span[normalize-space()='Account & Lists']"))).build().perform();
a.moveToElement(driver.findElement(By.xpath("//a[contains(text(),'Mobiles')]"))).click().build().perform();
driver.navigate().back();
a.moveToElement(driver.findElement(By.xpath("//input[@id='twotabsearchtextbox']"))).click().sendKeys("pen driver").doubleClick().build().perform();
//a.doubleClick(driver.findElement(By.xpath("//input[@id='twotabsearchtextbox']")));
//a.moveToElement(driver.findElement(By.xpath("//a[@href='/gp/bestsellers/?ref_=nav_cs_bestsellers']"))).contextClick().build().perform();
a.contextClick(driver.findElement(By.xpath("//a[@href='/gp/bestsellers/?ref_=nav_cs_bestsellers']"))).build().perform();
}
}
Watch following video:
Watch on YouTube: https://www.youtube.com/watch?v=FvgFIaa7nYk
No comments:
Post a Comment