in Selenium by
Q:
How to assert the title of a webpage?

► Click here to show 1 Answer

0 votes
by
Get the title of the webpage and store in a variable

    String actualTitle = driver.getTitle();

Type in the expected title

   String expectedTitle = “abcdefgh";

Verify if both of them are equal

   if(actualTitle.equalsIgnoreCase(expectedTitle))

   System.out.println("Title Matched");

  else

  System.out.println("Title didn't match");

Alternatively,

   Assert.assertEquals(actualTitle, expectedTitle);
Selenium
Learn More with Madanswer

Related questions

0 votes
asked Jan 30, 2020 in Selenium by Deepanshu Burreja
...