Using Selenium Webdriver in C#, how do I select a text box to write in, then write in it? Using Selenium Webdriver in C#, how do I select a text box to write in, then write in it? selenium selenium

Using Selenium Webdriver in C#, how do I select a text box to write in, then write in it?


You will need to give us some HTML of the page, but given a password textbox like this:

<input type="password" id="passwordTextBox">

I'd find it using Selenium's WebDriver like so:

IWebDriver firefoxDriver = new FirefoxDriver();IWebElement passwordTextBox = firefoxDriver.FindElement(By.Id("passwordTextBox"));

I would then 'write' into it like so:

passwordTextBox.Clear();passwordTextBox.SendKeys("password");

I would take a look at the Selenium Web Driver documentation, and ask any questions after you've read through it all:

http://seleniumhq.org/docs/03_webdriver.html


//Textbox  id is "username"IWebDriver driver = new ChromeDriver();    string url = "https://www.google.com";IWebElement textBox;driver.Navigate().GoToUrl(url);textBox = driver.FindElement(By.Name("username"));textBox.SendKeys("Test text");


driver.FindElement(selectBy(controlToFind, search)).Click();

Just need to use this code.

  • driver = your selenium web driver
  • SelectBy(controlToFind) = this is your control, xpath code, CSS selector or class.
  • .Click() = Represents the action to do, you can use .click() , .SendKeys() , wait() ...