ses ses - 17 days ago 9
Java Question

Selenium WebDriver getText

I have a

<div name="myDiv">0</div>
.

I try to write a test that myDiv has 0 text in it. With WebDriver it is:

String text = webDriver.findElement(By.xpath("//div[@name='myDiv']")).getText();


but in the result I have an empty string. Shouldn't I use getText() for getting a content of a div?

ses ses
Answer

I found an answer, I just need use real browser for my webDriver

webDriver = new FirefoxDriver();

then it works.

Maybe it is JavaScript issue.