How to check if some text is present on a web page using selenium 2?


Hi I am using selenium to automate test on web pages. I am using selenium 2 and python and would like to have answers in this framework only. SO how do I check whether some text is present or not? I have tried asset equals but it is not working?

assertEquals(driver.getPageSource().contains("email"), true);
6/11/2012 11:13:03 AM

You can use driver.page_source and a simple regular expression to check if the text exists:

import re    
src = driver.page_source
text_found ='text_to_search', src)
self.assertNotEqual(text_found, None)
6/20/2013 9:03:44 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow