C# Get text out of input textbox Selenium

474 views
Skip to first unread message

Daryl Bennett

unread,
Mar 24, 2014, 7:36:17 PM3/24/14
to seleniu...@googlegroups.com
Hi, 
I'm using Firefox and C# to develop my Selenium script. I have a basic question about getting text out of an input field;

I have a textbox named address that looks like this:
 <td><input id='address' class='contact' placeholder= 'Please Enter Address' required type='text' name='address'
         value='123 University Ln'/></td>

And here is the c# code that i use to try to retrieve the text value. (Which is '123 University Ln' Which was inputted by a user)

            address = driver.FindElement(By.Id("address"));
             Console.WriteLine("DEBUG address: " +address.Text);

address.Text returns empty... How do I get the text from the text inputbox?

Thanks, Daryl



Craig S

unread,
Mar 25, 2014, 8:08:45 AM3/25/14
to seleniu...@googlegroups.com
address = driver.FindElement(By.Id("address")).GetAttribute("value");
Reply all
Reply to author
Forward
0 new messages