0 votes
in Selenium by
How to assert the title of a webpage?

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

Related questions

0 votes
asked Mar 31, 2021 in Selenium by sharadyadav1986
0 votes
asked Jan 30, 2020 in Selenium by Deepanshu Burreja
...