Equivalent of isTextPresent of Selenium 1 (Selenium RC) in Selenium 2 (WebDriver)

Thomas Vervik picture Thomas Vervik · Oct 9, 2011 · Viewed 21.2k times · Source

There's no isTextPresent in Selenium 2 (WebDriver)

What is the correct way to assert the existence of some text on a page with WebDriver?

Answer

Thomp picture Thomp · Oct 10, 2011

I normally do something along the lines of:

assertEquals(driver.getPageSource().contains("sometext"), true);

assertTrue(driver.getPageSource().contains("sometext"));