Selenium - chrome Driver fail to start in background (without a start-up window)

后端 未结 3 1389
日久生厌
日久生厌 2021-01-16 11:57

I am using Selenium and trying to initialize the Chrome driver to start without a start up window.

ChromeOptions options= new ChromeOptions();
options.addAr         


        
3条回答
  •  一整个雨季
    2021-01-16 12:29

    You need to download the binary first from selenium website, download binary according to your specifications:-

    http://chromedriver.storage.googleapis.com/index.html?path=2.19/
    

    Now set below code so selenium script will know the path of your binary

    System.setProperty("webdriver.chrome.driver","./src\\lib\\chromedriver.exe");
    

    So the code should be like this:-

    System.setProperty("webdriver.chrome.driver","./src\\lib\\chromedriver.exe");
    ChromeOptions options= new ChromeOptions();
    options.addArguments("--no-startup-window");
    //I tried this line also: options.addArguments("--silent-launch");
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    WebDriver driver = new ChromeDriver(capabilities);
    

    Hope it will help you :)

提交回复
热议问题