将chromeOptions参数传递到Linux上.json文件中的selenium节点

将chromeOptions参数传递到Linux上.json文件中的selenium节点,json,linux,selenium,selenium-webdriver,chrome-options,Json,Linux,Selenium,Selenium Webdriver,Chrome Options,我正在尝试使用以下配置创建节点: java -Dwebdriver.chrome.driver=/randomfolder/chromedriver -jar selenium-server-standalone-3.4.0.jar -role node -nodeConfig node-conf.json 如您所见,我正在json文件中传递config。它可以正确设置配置,但chromeOptions除外。我需要无头打开。这是my.json文件的一部分,用于设置功能 "capabilitie

我正在尝试使用以下配置创建节点:

java -Dwebdriver.chrome.driver=/randomfolder/chromedriver -jar selenium-server-standalone-3.4.0.jar -role node -nodeConfig node-conf.json
如您所见,我正在json文件中传递config。它可以正确设置配置,但chromeOptions除外。我需要无头打开。这是my.json文件的一部分,用于设置功能

"capabilities": [
    {  
         "browserName":"chrome",
         "maxInstances":3,
         "version":"ServerLinux",
         "platform":"LINUX",
         "chromeOptions": {
            "args": ["--headless", "--disable-gpu" , "--window-size=1920x1080", "--no-sandbox"]
         }
     }
   ]
我尝试了不同的方法来编写chromeOptions,但node总是忽略它们。难道我只是瞎了眼,看不到我的错误吗?
提前谢谢

我也面临着这个问题,但就我而言,我想修改用户代理,而在Linux上,chromeOptions似乎被忽略了。这对我在Mac/Chrome上的本地应用是有效的

//wdio.conf.js
capabilities: [{
    browserName: "chrome",
    chromeOptions : {
        args : ['--user-agent=THIS_IS_A_TEST']
    }
  }],

//Jenkins job on Linux RHEA
13:42:33 [11/10/2018 13:42:33.049] [LOG]   browser.desiredCapabilities = {
13:42:33   "javascriptEnabled": true,
13:42:33   "locationContextEnabled": true,
13:42:33   "handlesAlerts": true,
13:42:33   "rotatable": true,
13:42:33   "browserName": "chrome",
13:42:33   "acceptInsecureCerts": true,
13:42:33   "chromeOptions": {
13:42:33     "args": [
13:42:33       "--user-agent=THIS_IS_A_TEST",
13:42:33       "window-size=1600,1200"
13:42:33     ]
13:42:33   },
13:42:33   "loggingPrefs": {
13:42:33     "browser": "ALL",
13:42:33     "driver": "ALL"
13:42:33   }
13:42:33 }
13:42:33 [11/10/2018 13:42:33.072] [LOG]   printNavigatorUserAgent() navigator.userAgent = Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36
应为:printNavigatorUserAgent()navigator.userAgent=此为测试

printNavigatorUserAgent(){

  let result = browser.execute(function() {
      return navigator.userAgent;
  },);

  console.log(`printNavigatorUserAgent() navigator.userAgent = ${result.value}`);

}
更新:以下语法目前在Linux/chrome上适用

//wdio.conf.js
capabilities: [{
  browserName: "chrome",
    "goog:chromeOptions" : {
      "args" : ['user-agent=THIS_IS_A_TEST']
  }
}],

我们可以看到您将
功能
传递给
WebDriver
实例吗?