|
Darrell |
at Nov 12, 2012 at 1:49 pm
|
⇧ |
| |
As pointed out, the getText() method gets the CDATA between the open and
close tag. For example, given <b>text</b> the getText() would get the
"text" string. If you look at the the input tag you should see something
like: <input id="foo" value="text"/>. There is no CDATA and therefore the
getText() will return nothing.
Personally, I choice to use WebDriver and not fall back on Selenium. The
getAttribute() method can be used to get the value of an input tag, e.g.
WebElement we = driver.findElement(By.id("foo"));
String value = we.getAttribute("value");
This works for the example input tag I provided. Obviously, you'd replace
the first line with the line which finds your input element.
Darrell
On Monday, 12 November 2012 07:49:22 UTC-5, divya angel wrote:
i need to extract the text present in the input field...the text displays
only after the above fields are entered..
String name=driver.findElement(By.xpath("//*[@id='vo_name']")).getText();
System.out.println(name);
but the text was not displaying?
--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/webdriver/-/Xb8g2HL8hQgJ.To post to this group, send email to webdriver@googlegroups.com.
To unsubscribe from this group, send email to webdriver+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/webdriver?hl=en.