Headless automation with Nodejs Selenium Webdriver

后端 未结 4 1665
眼角桃花
眼角桃花 2021-01-30 18:30

I am working with an automation tool which has to be deployed inside an ubuntu server, my wonder is if is possible to use chrome in a silent way with Selenium Webdriver.

4条回答
  •  清歌不尽
    2021-01-30 19:16

    Updated answer circa FEB-2018.

    Referencing the Selenium Webdriver NodeJS Examples (commit 5bf50c4)

    const chrome = require('selenium-webdriver/chrome');
    const firefox = require('selenium-webdriver/firefox');
    const {Builder, By, Key, until} = require('selenium-webdriver');
    
    const screen = {
      width: 640,
      height: 480
    };
    
    let driver = new Builder()
        .forBrowser('chrome')
        .setChromeOptions(new chrome.Options().headless().windowSize(screen))
        .setFirefoxOptions(new firefox.Options().headless().windowSize(screen))
        .build();
    

    Headless Chrome available since major version 59.0 APR-2017

    Headless Firefox available since major version 56.0 SEP-2017

提交回复
热议问题