hxm154

要把ChromeDriver放到代码中的文件夹中c://*******Application

    public static WebDriver WebDriverRun(WebDriver driver){
//            System.setProperty(Dom4jXml.getValue("chromeDriverName"), Dom4jXml.getValue("chromeDriverPath"));
            // 设置 chrome 的路径  
            System.setProperty(  
                "webdriver.chrome.driver",  
                "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe");  
            webdriver = new ChromeDriver(chromeOptions());
            
            // 转型为WebDriver, 统一类型,方便调用异常截图方法
            RuntimeServer runtime = new RuntimeServer();
            runtime.runtimeDriver(webdriver);
//            driver = chromeOptions();
            //driver = new FirefoxDriver();
            return webdriver;
    }
    
    /**
     * 禁止chrome弹出忽略网站证书错误提示
     * @return
     */
    public static ChromeOptions chromeOptions(){
            ChromeOptions options = new ChromeOptions();
//            DesiredCapabilities capabilities = DesiredCapabilities.chrome();
//            capabilities.setCapability("chrome.switches", Arrays.asList("--start-maximized"));
//            options.addArguments("--test-type", "--start-maximized");
            options.addArguments("--test-type", "--ignore-certificate-errors");
            
            return options;
    }

分类:

技术点:

相关文章:

  • 2021-11-22
  • 2021-11-22
  • 2021-12-07
  • 2022-02-01
  • 2021-11-15
  • 2021-08-04
  • 2021-06-26
猜你喜欢
  • 2021-09-10
  • 2021-11-22
  • 2021-10-16
  • 2021-10-27
  • 2021-10-20
  • 2021-07-09
  • 2021-09-25
相关资源
相似解决方案