Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Have a script to go to the website. Now I want to login and proceed to next screen. Can't find code on how to go to 'username:' text box, then 'password:' text box.

like image 735
lbrown Avatar asked May 11 '12 19:05

lbrown


1 Answers

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

like image 176
Arran Avatar answered Sep 30 '22 12:09

Arran