Skip to content

Instantly share code, notes, and snippets.

@bharathmuddada
Created August 7, 2022 16:05
Show Gist options
  • Save bharathmuddada/3042a5ec5eafce90243adf59ac905919 to your computer and use it in GitHub Desktop.
Save bharathmuddada/3042a5ec5eafce90243adf59ac905919 to your computer and use it in GitHub Desktop.
Selenium c# program to hover over a element
public class HoverExample {
public static void Main(string[] args) {
new DriverManager().SetUpDriver(new ChromeConfig());
var driver = new ChromeDriver();
driver.Navigate().GoToUrl("https://the-internet.herokuapp.com/hovers");
driver.Manage().Window.Maximize();
var user1_element = driver.FindElement(By.XPath("//div[@class='figure'][1]"));
Actions actions = new Actions(driver);
actions.MoveToElement(user1_element).Perform();
Console.WriteLine(driver.FindElement(By.XPath("//h5")).Text);
driver.FindElement(By.XPath("(//div[@class='figcaption']//a)[1]")).Click();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment