I'm using Selenium WebDriver for C# and want to get username and password from console. My code is:
var username = Console.ReadLine();
var password = Console.ReadLine();
// open application
driver.Navigate().GoToUrl("http://myurl");
// enter username and password, press enter
driver.FindElement(By.Id("Username")).SendKeys(username);
driver.FindElement(By.Id("Password")).SendKeys(password);
driver.FindElement(By.Id("Password")).SendKeys(Keys.Enter);
But Console.ReadLine() not working in Unit Test Project.
What is the best way to do it?
Use this:
RépondreSupprimervar input = new StringReader("Test input");
Console.SetIn(input);