using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace MySeleniumApp
{
class Program
{
static void Main(string[] args)
{
// Initialize the Chrome Driver
using (IWebDriver driver = new ChromeDriver())
{
// Navigate to a website
driver.Navigate().GoToUrl("https://www.example.com");
// Find element by its class name
IWebElement element = driver.FindElement(By.ClassName("element_class_name_here"));
// Perform actions on the element (e.g., click, send keys, etc.)
string elementText = element.Text;
// Output the text of the element
Console.WriteLine($"Element text is: {elementText}");
// Close the driver
driver.Quit();
}
}
}
}
Related