我正在使用一个必须部署在ubuntu服务器内的自动化工具,我不知道是否可以使用Selenium Webdriver以静默方式使用chrome.
到目前为止,我已经尝试了以下代码,但它一直打开浏览器(我在Windows 10中进行测试):
var webdriver = require('selenium-webdriver'),
chrome = require('selenium-webdriver/chrome')
By = webdriver.By,
until = webdriver.until,
options = new chrome.Options();
options.addArguments('--headless');
var path = require('chromedriver').path;
var service = new chrome.ServiceBuilder(path).build();
chrome.setDefaultService(service);
var driver = new webdriver.Builder().forBrowser('chrome').withCapabilities(options.toCapabilities()).build();
driver.get('https://www.google.com');
Run Code Online (Sandbox Code Playgroud)
请注意,addArguments(' - headless')是应该使导航无声的参数,但显然它不起作用或者我遗漏了一些我不知道的东西.
如果有一些我遗失的东西,请告诉我,因为我不知道我想做什么是可能的,因为这是我使用这种技术的第一次.
谢谢.