How to verify the title of the page using Selenium Webdriver











package mypackagefirefox;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Verifylink {

 public static void main(String[] args) {
  // TODO Auto-generated method stub

  
  //Set the path of the driver
  String exepath = "C:\\Users\\mn\\Downloads\\geckodriver-v0.19.1-win64//geckodriver.exe";
  System.setProperty("webdriver.gecko.driver", exepath);
  
  WebDriver driver = new FirefoxDriver (); 
 
  String expectedtitle ="Testing Treasure";
  String actualtitle = "";
  
  //Launch firefox and open URL
  driver.get("http://www.testingtreasure.com");
  
  // get the actual value of the title
  actualtitle=driver.getTitle();
  
  
  /*
         * compare the actual title of the page with the expected one and print
         * the result as "Passed" or "Failed"
         */
  if(actualtitle.contentEquals(expectedtitle))
  {
   System.out.println("test is pass");
  }
     
  else{
   System.out.println("test is fail");
  }
  
 }

}



0 comments:

Post a Comment