ses ses - 1 month ago 33
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

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

webDriver = new FirefoxDriver();

then it works.

Maybe it is JavaScript issue.