Goes to a web page and prints title - Java HTML

Java examples for HTML:selenium

Description

Goes to a web page and prints title

Demo Code

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.By;

import java.net.URL;

public class Main {

    public static void main(String[] args) throws Exception {

        WebDriver driver = new FirefoxDriver();

        driver.get("http://your server.com/");
        driver.findElement(By.id("ham")).click();

        System.out.println("title of page is: " + driver.getTitle());

        driver.quit();// w ww. j a v  a  2  s.  c om
    }
}

Related Tutorials