What is use of driver.getTitle() in selenium?

Subhajit Manna
Subhajit Manna

Posted On: Apr 08, 2020

 

driver. getTitle() process will capture the current started page heading and later it will be saved in a variable and next it will be published in the console. Presently you can utilize its usefulness for other purposes too. You may do the same thing utilizing "storeTitle" Command in selenium IDE.

Example Code

parcel Testing_Pack;
import org.junit.Assert;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class mytestclass {

 public static void main(String[] args) {
  WebDriver driver = new FirefoxDriver();
   Driver.get;
  String i = driver.getCurrentUrl();
  System.out.println(i);
  String j = driver.getTitle();
  System.out.println("Your page title Is : "+j);
  Assert.assertEquals("Only Testing",j);
  Assert.assertEquals("Only Testing",driver.getTitle());
  driver.close();
 }
}

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Cognizant Testing interview questions

    Explain what is STLC?

    STLC stands for Software Testing Life Cycle. STLC happens to be a series of different actions implemented by the examination team to guarantee the condition of the product or the software. As promptly...

    Cognizant Testing interview questions

    What is syntax to Initialize browser in webdriver?

    By following the below-mentioned steps one may initiate browser in web driverAction 1: Download Chrome Drive Action 2: Unlock any browser and access http://www.seleniumhq.org/download/ Here you w...

    Cognizant Testing interview questions

    What is SDLC?

    Software Development Life Cycle (SDLC) is nothing but a process that is utilized by the software manufacturing sectors to develop, design and test high-quality software. The SDLC strives to manufactur...