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

后端 未结 3 1388
日久生厌
日久生厌 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 :)

    0 讨论(0)
  • 2021-01-16 12:32

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

    According to Selenium GitHub (Strange error, chromedriver with --no-startup-window), Selenium requires JavaScript and Chrome window to work:

    Much like --disable-javascript, the chromedriver will not work if you use --no-startup-window. It needs to launch a window to establish the connection with the AutomationProxy.

    0 讨论(0)
  • 2021-01-16 12:39

    I think the flag you are looking for is --headless This feature has just been implemented in chrome 57

    --no-startup-window is used for hosting background apps, see this page and as mentioned in the other answers doesn't launch a window which is why the webdriver can't talk to it.

    --headless does launch a window, but doesn't make it visible.

    0 讨论(0)
提交回复
热议问题