0 votes
1 view
in Devops and Agile by (19.8k points)

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

1 Answer

0 votes
by (63.4k points)

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");

 }

Hope this helps!

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...