package com.mypro.test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class OpenIE {
public static void main(String[] args) {
System.setProperty("webdriver.ie.driver", ".\resource\IEDriverServer.exe");
//设置启动参数,关闭保护模式
DesiredCapabilities iecapabilities = DesiredCapabilities.internetExplorer();
iecapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
//启动浏览器
WebDriver driver = new InternetExplorerDriver(iecapabilities);
//最大化窗口
driver.manage().window().maximize();
//设置隐性等待时间
driver.manage().timeouts().implicitlyWait(8, TimeUnit.SECONDS);
//get()打开一个站点
driver.get("http://www.baidu.com");
//getTitle()获取当前页面title的值
System.out.println("当前打开页面的标题是:" + driver.getTitle());
//退出浏览器
driver.quit();
}
}
运行结果: