易百教程

32、编写一段代码以在 WebDriver 中启动 Internet Explorer 浏览器。

参考代码实现:

public class IEBrowserLaunchDemo {  

    public static void main(String[] args) {  

        //Creating a driver object referencing WebDriver interface  
        WebDriver driver;  

        //Setting the webdriver.ie.driver property to its executable's location  
        System.setProperty("webdriver.ie.driver", "/lib/IEDriverServer/IEDriverServer.exe");  

        //Instantiating driver object  
        driver = newInternetExplorerDriver();  

        //Using get() method to open a webpage  
        driver.get("http://yiibai.com");  

        //Closing the browser  
        driver.quit();  

    }  

}