Preparations:
- Get CoreCompat.Selenium.Webdriver
- Get a plugin for the browser you want to use for testing, e. g. Selenium.Firefox.WebDriver
- (optional) If you have issues with running the project you can place the executable for the plugin on your PATH environment variable
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
namespace SeleniumTutorial
{
class Program
{
static void Main(string[] args)
{
//Create a driver for a browser
IWebDriver driver = new FirefoxDriver();
//navigate to the page
driver.Navigate().GoToUrl("https://www.google.com/");
//find the search bar
IWebElement searchInput = driver.FindElement(By.Id("lst-ib"));
//send date to the seach bar
searchInput.SendKeys("trash panda" +Keys.Enter);
}
}
}