Reputation: 59
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
Reputation: 1
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("document.getElementById('xxxx').style.display='block';");
Upvotes: -3
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