import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
/*
* 返回当前页面 url 和 title
*/
public class GetUrlAndTitle {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.get("http://www.baidu.com");
System.out.println("当前页面 title : " + driver.getTitle());
System.out.println("当前页面 url : " + driver.getCurrentUrl());
System.out.println("当前页面源码: " + driver.getPageSource());
System.out.println("当前浏览器的窗口句柄: " + driver.getWindowHandle());
System.out.println("当前浏览器的所有窗口句柄: " + driver.getWindowHandles());
driver.quit();
}
}