chandra sekhar
chandra sekhar

Reputation: 59

How to get a textbox value using selenium webdriver & Java?

1) I have entered name in "Full Name" text box field.

 WebElement name = driver.findElement(By.id("userId"));
        name.sendKeys("Sekhar");

it has entered value in the textbox.

2) I have to validate that "Sekhar" is presented in the textbox. but here the problem is the value entered in the textbox is displaying in watermark logger.info(name.getText()); does not returning a value

because it is displayed in watermark in the textbox.

please help me how to get a watermark text in textbox.

Upvotes: 2

Views: 19266

Answers (2)

user7506035
user7506035

Reputation: 1

JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("document.getElementById('xxxx').style.display='block';");

Upvotes: -3

alecxe
alecxe

Reputation: 473873

It would depend on what do you mean by watermark and what is the HTML representation of the input element. But, this should be either a value attribute:

name.getAttribute('value');

or could be a placeholder:

name.getAttribute('placeholder');

Upvotes: 7

Related Questions