chrome setting drive

Package com.dn.UI; 

Import org.openqa.selenium.WebDriver;
 Import org.openqa.selenium.chrome.ChromeDriver;
 Import org.openqa.selenium.chrome.ChromeOptions; 

public  class GoogleDriver { // the Chrome browser driver class 
    private Driver = the WebDriver null ; 

    public GoogleDriver (String DriverPath) {
         // set chrome path 
        System.setProperty ( "webdriver.chrome.driver" , DriverPath); 
        ChromeOptions Option = new new ChromeOptions ();
         // remove the Google Chrome yellow caveat
        option.addArguments ( "- disable-infobars" );
         // load the user file chrome
 //         option.addArguments ( "- User-Data-the dir = C: \\ \\ the Users the Local PC \\ \\ \\ AppData the User the Data \\ \\ Chrome Google ");
         // maximize the browser window
 //         option.addArguments (" - Start-maximized ");
         // whitelist setting
 //         option.addArguments (" - whitelisted-IPS = \ "\" "); 

        // create a ChromeDriver interface for connecting Chrome
 //         DesiredCapabilities new new DesiredCapabilities the Capabilities = ();
 //         capabilities.setCapability (ChromeOptions.CAPABILITY, the Option);
 //        capabilities.setCapability(CapabilityType.BROWSER_NAME, "chrome");
//        capabilities.setCapability(CapabilityType.VERSION, "");
//        capabilities.setCapability(CapabilityType.PLATFORM, "WINDOWS");
        //启动chromedriver服务
//        ChromeDriverService service = null;
//        try {
//            service = new ChromeDriverService.Builder().usingDriverExecutable(new File(driverpath)).usingAnyFreePort()
//                    .build();
//            service.start();
////             service.stop();
//        } catch (IOException e) {
//            e.printStackTrace ();
 //             System.out.println ( "log - error:! Start Service error");
 //         } 

        the try { // create a Chrome browser instance
 //             this.driver new new RemoteWebDriver = ( service.getUrl (), Capabilities); 
            the this .driver = new new ChromeDriver (Option);
             // allow the browser to access a blank page 
            driver.get ( "About: blank" ); 
        } the catch (Exception E) { 
            e.printStackTrace () ; 
            System.out.println ( "log - error: failed to create Googledriver !!" ); 
        } 

    } 

    public WebDriver getdriver() {
        return this.driver;
    }
}

 

Guess you like

Origin www.cnblogs.com/lemom/p/11484854.html