palantirnet / the-vagrant

Install a Vagrant environment into a Drupal project.
2 stars 1 forks source link

Add role to install selenium, chrome, and chromedriver. #61

Closed damontgomery closed 5 years ago

damontgomery commented 5 years ago

The behat.yml configuration I tested with looks something like,

default:
  suites:
    default:
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
      filters:
        tags: "~@skipci"
  gherkin:
    cache: ~
  extensions:
    Behat\MinkExtension:
      browser_name: 'chrome'
      selenium2:
        wd_host: "http://127.0.0.1:4444/wd/hub"
        capabilities: { "browserName": "chrome", "browser": "chrome", "version": "62", 'chrome': {'switches':['--no-sandbox', '--headless']}}
      javascript_session: selenium2
      base_url: [INSERT HERE]
    Drupal\DrupalExtension:
      blackbox: ~
      api_driver: 'drupal'
      drupal:
        drupal_root: 'web'
      text:
        username_field: 'name'
        password_field: 'pass'
        log_out: 'Log out'
      region_map:
        anywhere: "*"

circle:
  extensions:
    Behat\MinkExtension:
      base_url: [INSERT HERE]:8000

The critical part was,

    Behat\MinkExtension:
      browser_name: 'chrome'
      selenium2:
        wd_host: "http://127.0.0.1:4444/wd/hub"
        capabilities: { "browserName": "chrome", "browser": "chrome", "version": "62", 'chrome': {'switches':['--no-sandbox', '--headless']}}
      javascript_session: selenium2
      base_url: [INSERT HERE]

I also created a Phing script to start the selenium server. I couldn't get it to stay on when I tried to add it to the Ansible part. Maybe someone else has ideas for that.

    <target name="start-selenium">
        <exec command='java -jar -Dwebdriver.chrome.driver="/usr/local/share/chromedriver/chromedriver" /usr/local/share/selenium/selenium-server-standalone.jar >/dev/null 2>&amp;1 &amp;' dir="/home" />
    </target>