Equivalent of isTextPresent of Selenium 1 (Selenium RC) in Selenium 2 (WebDriver)
Or if you want to actually check the text content of a WebElement you could do something like:
assertEquals(getMyWebElement().getText(), "Expected text");
I normally do something along the lines of:
assertEquals(driver.getPageSource().contains("sometext"), true);
assertTrue(driver.getPageSource().contains("sometext"));
I know this is a bit old, but I found a good answer here: Selenium 2.0 Web Driver: implementation of isTextPresent
In Python, this looks like:
def is_text_present(self, text):
try: el = self.driver.find_element_by_tag_name("body")
except NoSuchElementException, e: return False
return text in el.text
Page source contains HTML tags which might break your search text and result in false negatives. I found this solution works much like Selenium RC's isTextPresent API.
WebDriver driver = new FirefoxDriver(); //or some other driver
driver.findElement(By.tagName("body")).getText().contains("Some text to search")
doing getText and then contains does have a performance trade-off. You might want to narrow down search tree by using a more specific WebElement.