Hey Janvi, you can verify a page's title by using following test script:
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Verify_Page_Title {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://edureka.co");
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
String Actual = driver.getTitle();
String Expected = "Instructor-Led Online Training with 24X7 Lifetime Support | Edureka";
if (Actual.equals(Expected)) {
System.out.println("Test Passed!");
} else {
System.out.println("Test Failed");
}
driver.close();
}
}
For further understanding, you can refer to the Selenium Course.