Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium WebDriver get text from input field

Tags:

selenium

I'm writing a test to assert the default text value within an <input> tag. However, it's not playing ball:

Assert.assertThat(webDriver.findElement(By.id("inputTag")).getText(), Matchers.is("2"));
like image 575
Matthew Avatar asked Mar 24 '16 14:03

Matthew


1 Answers

This is the input element - you need to get the value attribute:

webDriver.findElement(By.id("inputTag")).getAttribute("value")
like image 129
alecxe Avatar answered Oct 02 '22 23:10

alecxe