Skip to content

Instantly share code, notes, and snippets.

@bharathmuddada
Created August 7, 2022 15:30
Show Gist options
  • Save bharathmuddada/92492a0d03d788a423033a4c0b8fe173 to your computer and use it in GitHub Desktop.
Save bharathmuddada/92492a0d03d788a423033a4c0b8fe173 to your computer and use it in GitHub Desktop.
Selenium C# script examples for RIght Click and Double Click example
public class RightClickDoubleClick {
public static void Main(string[] args) {
new DriverManager().SetUpDriver(new ChromeConfig());
var driver = new ChromeDriver();
driver.Navigate().GoToUrl("https://demo.guru99.com/test/simple_context_menu.html");
driver.Manage().Window.Maximize();
var right_click_field = driver.FindElement(By.XPath("//span[@class='context-menu-one btn btn-neutral']"));
var double_click_field = driver.FindElement(By.XPath("//button[contains(text(),'Double-Click')]"));
Actions actions = new Actions(driver);
actions.ContextClick(right_click_field).Perform();
var edit_link = driver.FindElement(By.XPath("//*[@id='authentication']/ul/li[1]"));
edit_link.Click();
driver.SwitchTo().Alert().Accept();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment