How To verify the Page title in Selenium Webdriver


 verifying the Page title in Selenium Webdriver-

Selenium Code for verify the page title

package automationtesting;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Gettitle {
       public static void main(String[] args) throws InterruptedException {
              // TODO Auto-generated method stub
             
              System.setProperty("webdriver.chrome.driver","D:\\Sandeep\\Soft\\chromedriver.exe");
              WebDriver driver= new ChromeDriver();
              driver.manage().window().maximize();
              driver.get("https://www.facebook.com/");
              System.out.println( driver.getTitle());
              //Get The Title
              String titl=driver.getTitle();
              //Verify The Title
              if (titl.equals("Facebook – log in or sign up"))
              {
                     System.out.println("True");
              }
                     else {
                           System.out.println("False");
                     }
              }

                    

}

Post a Comment

0 Comments