Unable to run tests in headless mode; it doesn't seem to be an issue with snippet, cos i tried it in different ways and outcome is the same.
caps = Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { binary: "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome",
args: [ "--headless" ]})
@driver = Selenium::WebDriver.for :chrome, desired_capabilities: caps
Error
unknown error: cannot get automation extension
from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
(Session info: headless chrome=59.0.3071.115)
(Driver info: chromedriver=2.31.488774 (7e15618d1bf16df8bf0ecf2914ed1964a387ba0b),platform=Mac OS X 10.12.3 x86_64) (Selenium::WebDriver::Error::UnknownError)
Chrome browser: 59.0.3071.115 (latest)
Chrome driver: chromedriver=2.31.488774 (latest)
Language used: Ruby
This is a known issue in chromedriver. As mentioned in the github
This is a long standing issue with Chromedriver. The window resizing doesn't work with the chromedriver and the community is silent on this bug fix. If the resizing is not critical for your tests, I would suggest you avoid the manage() method altogether and use a workaround of having your browser window always maximized using the ChromeOptions object at the launch of your chromedriver instantiation.
Though it is not happening to everyone, the issue still exists. It is mostly resolved by updating chrome or chromedriver to the latest version(still wont work for most people)
So better not to use maximize or resizing activity on chrome .However if you want, you can go with ChromeOptions
which is suggested by ChromeDriver
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");