返回当前页面title、url等操作
1 import org.openqa.selenium.WebDriver; 2 import org.openqa.selenium.chrome.ChromeDriver; 3 4 /* 5 * 返回当前页面 url 和 title 6 */ 7 public class GetUrlAndTitle { 8 9 public static void main(String[] args) { 10 WebDriver driver = new ChromeDriver(); 11 12 driver.get("http://www.baidu.com"); 13 14 System.out.println("当前页面 title : " + driver.getTitle()); 15 16 System.out.println("当前页面 url : " + driver.getCurrentUrl()); 17 18 System.out.println("当前页面源码: " + driver.getPageSource()); 19 20 System.out.println("当前浏览器的窗口句柄: " + driver.getWindowHandle()); 21 22 System.out.println("当前浏览器的所有窗口句柄: " + driver.getWindowHandles()); 23 24 driver.quit(); 25 } 26 }