Selenium Java to get the title of a given webpage using getTitle() method
KW.java
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

class KW 
{
    public static void main(String[] args) 
    {
        System.setProperty("webdriver.chrome.driver", "/home/kodingwindow/drivers/chromedriver");
        WebDriver driver = new ChromeDriver();
        driver.navigate().to("https://kodingwindow.com/testapp/");
        System.out.println(driver.getTitle());
        driver.close();
    }
}
Output
Kodingwindow's TestApp

Advertisement