How to make a basic Chrome Selenium program C#
Here are some core script examples of the very basic functions selenium is capable of. In this example it shows how to navigate to a url (site), click a button/enter in an input using XPath to find the elements, and then finally closes both the chrome window and console window.
// Put the path of your chrome driver here.
IWebDriver driver = new ChromeDriver(DRIVERPATH);
// Navigates to the URL you want to be on, which in this example is this site.
// Waits one second for the site elements to be loaded.
// Clicks the button on the site.
// Enters text into the input on the site.
driver.FindElement(By.XPath("/html/body/input")).SendKeys("Selenium is awesome :D");
// Waits ten seconds and then closes down the driver and program
// Take the program out of a static loop to use the driver variable.
static void Main()
Example example = new Example();
Created [September 2, 2021]