Back
I'm using Selenium WebDriver, how can I check if some text exists or not on the page? Maybe someone recommends me useful resources where I can read about it. Thanks
In Java use the following function:
public void verifyTextPresent(String value) { driver.PageSource.Contains(value); } and the usage would be: try { Assert.IsTrue(verifyTextPresent("Selenium Wiki")); Console.WriteLine("Selenium Wiki test is present on the home page"); } catch (Exception){ Console.WriteLine("Selenium Wiki test is not present on the home page"); }
public void verifyTextPresent(String value)
{
driver.PageSource.Contains(value);
}
and the usage would be:
try {
Assert.IsTrue(verifyTextPresent("Selenium Wiki"));
Console.WriteLine("Selenium Wiki test is present on the home page");
catch (Exception)
Console.WriteLine("Selenium Wiki test is not present on the home page");
Hope this helps!
31k questions
32.8k answers
501 comments
693 users