1
+ package com .SeleniumPractice ;
2
+
3
+ import org .openqa .selenium .Alert ;
4
+ import org .openqa .selenium .By ;
5
+ import org .openqa .selenium .WebDriver ;
6
+ import org .openqa .selenium .chrome .ChromeDriver ;
7
+ import org .openqa .selenium .interactions .Actions ;
8
+
9
+ import io .github .bonigarcia .wdm .WebDriverManager ;
10
+
11
+ /**
12
+ * @author Yadagiri Reddy
13
+ * How to perform below operations using Selenium WebDriver?
14
+ * MoveToElement or MouseHover,
15
+ * Click,
16
+ * Double Click,
17
+ * Right click or Context Click
18
+ */
19
+ public class TestActions {
20
+ public static void main (String [] args ) throws Exception {
21
+ WebDriverManager .chromedriver ().setup ();
22
+ WebDriver driver = new ChromeDriver ();
23
+ driver .manage ().window ().maximize ();
24
+ Actions actions = new Actions (driver );
25
+
26
+ // driver.get("https://opensource-demo.orangehrmlive.com/");
27
+ // driver.findElement(By.id("txtUsername")).sendKeys("Admin");
28
+ // driver.findElement(By.id("txtPassword")).sendKeys("admin123");
29
+ // driver.findElement(By.id("btnLogin")).click();
30
+ //
31
+ // actions
32
+ // .moveToElement(driver.findElement(By.id("menu_admin_viewAdminModule")))
33
+ // .moveToElement(driver.findElement(By.id("menu_admin_Organization")))
34
+ // .moveToElement(driver.findElement(By.id("menu_admin_viewLocations")))
35
+ // .click()
36
+ // .perform();
37
+ //
38
+ // driver.findElement(By.id("searchLocation_name")).sendKeys("Hyderabad");
39
+ // actions.doubleClick(driver.findElement(By.id("searchLocation_name"))).perform();
40
+
41
+
42
+ driver .get ("https://swisnl.github.io/jQuery-contextMenu/demo.html" );
43
+ actions .contextClick (driver .findElement (By .xpath ("//span[.='right click me']" ))).perform ();
44
+ Thread .sleep (3000 );
45
+ driver .findElement (By .xpath ("//li[.='Edit']" )).click ();
46
+ Thread .sleep (3000 );
47
+ Alert alert = driver .switchTo ().alert ();
48
+ System .out .println (alert .getText ());
49
+ alert .accept ();
50
+ }
51
+ }
0 commit comments