This playbook will download and install the latest version of Chrome and ChromeDriver.
The latest version of ChromeDriver allows you to run Chrome browser in headless mode without Selenium and doesn't need any Display server or Xvfb.
- git
- ansible
- codeception (for tests)
- Clone this repo with git
$ git clone https://github.com/marvin-neumann/ansible-chrome-headless.git
- Then run the playbook with ansible-playbook
$ ansible-playbook -l localhost ansible-chrome-headless/playbook.yml --ask-sudo-pass
- Change the
acceptance.suite.yml
in your tests directory, put everything below in theWebdriver
part und change the url.
WebDriver:
url: 'http://example.com/'
browser: chrome
port: 9515
window_size: false
capabilities:
chromeOptions:
args: ["--headless", "--disable-gpu", "window-size=1920x1080"]
binary: "/usr/bin/google-chrome"
- Start ChromeDriver, the binary is placed in
/usr/local/bin
so you can call it from anywhere
$ chromedriver --url-base=/wd/hub --whitelisted-ips='' --verbose
- Then run your tests.
Even though you are writing valid tests, there are a few problems that can occur when running some versions of ChromeDriver.
- If an element cannot be clicked because it is outside the viewport, you have to scroll to the element first, then click the element.
$I->scrollTo('button.outside-viewport');
$I->click(['css' => 'button.outside-viewport']);;
- If filling a date input field with the
fillField
action doesn't work, use thepressKey
action instead.
# if this doesn't work
$I->fillField('input#date', '2017-08-31');
# use this instead
$I->pressKey('input#date', '2017-08-31');