jsonlinuxseleniumselenium-webdriverchrome-options

Passing chromeOptions args to the selenium node in .json file on Linux


I'm trying to create node with following configurations:

java -Dwebdriver.chrome.driver=/randomfolder/chromedriver -jar selenium-server-standalone-3.4.0.jar -role node -nodeConfig node-conf.json

As you see I'm passing config in a json file. It sets the configurations correctly, except the chromeOptions. I need chrome to be opened headless. This is a part of my .json file, which sets the capabilities.

"capabilities": [
    {  
         "browserName":"chrome",
         "maxInstances":3,
         "version":"ServerLinux",
         "platform":"LINUX",
         "chromeOptions": {
            "args": ["--headless", "--disable-gpu" , "--window-size=1920x1080", "--no-sandbox"]
         }
     }
   ]

I've tried different ways of writing the chromeOptions, but node keeps constantly ignoring them. Am I just blind and don't see my mistake? Thanks in advance!


Solution

  • I am also facing this issue, but in my case, I want to modify the user agent, and on Linux, chromeOptions just seems to be ignored. This is working for me locally on 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
    

    Expected: printNavigatorUserAgent() navigator.userAgent = THIS_IS_A_TEST

    printNavigatorUserAgent(){
    
      let result = browser.execute(function() {
          return navigator.userAgent;
      },);
    
      console.log(`printNavigatorUserAgent() navigator.userAgent = ${result.value}`);
    
    }
    

    Update: The following syntax is currently working for me on Linux/chrome.

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