Ruprit
Ruprit

Reputation: 743

Behat + mink + Selenium2 + chromeDriver: Do not launch chrome browser

I am using ubuntu 14.4.

When I run the test its works fine with firefox, where it launches the FF browser.

But when I try the same with Chrome the test runs but it do not launch the browser.

composer.json

{
    "require": {
    "behat/behat": "2.4.*@stable",
    "behat/mink": "1.5.*@stable",
    "behat/mink-goutte-driver": "*",
    "behat/mink-extension": "*",
    "behat/mink-selenium2-driver": "*"
    }
}

behat.yml

default:
 paths:
  features: features
  bootstrap: %behat.paths.features%/bootstrap
 extensions:
  Behat\MinkExtension\Extension:
    base_url:  'path-to-my-site'
    default_session: selenium2
    browser_name: 'chrome'
    goutte: ~
    selenium2:
        wd_host: "http://127.0.0.1:4444/wd/hub"

Command to start Selenium Server

java -jar /path-to/selenium-server-standalone-2.47.1.jar -Dwebdriver.chrome.driver="/usr/local/share/chromedriver"

This is output of my above command:

11:27:46.064 INFO - Launching a standalone Selenium Server
Setting system property webdriver.chrome.driver to /usr/local/share/chromedriver
11:27:46.101 INFO - Java: Oracle Corporation 24.72-b04
11:27:46.101 INFO - OS: Linux 3.13.0-32-generic amd64
11:27:46.113 INFO - v2.47.1, with Core v2.47.1. Built from revision 411b314
11:27:46.181 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match the current platform LINUX
11:27:46.182 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{platform=WINDOWS, browserName=MicrosoftEdge, version=}] does not match the current platform LINUX
11:27:46.182 INFO - Driver class not found: com.opera.core.systems.OperaDriver
11:27:46.182 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
11:27:46.249 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
11:27:46.249 INFO - Selenium Server is up and running

Behat test command:

vendor/bin/behat

Output of behat test

Feature: Home page
    I am on a home page

  Scenario: Visit homepage                       # features/test.feature:4
    Given I go to "home.html"                    # FeatureContext::visit()
    Then I should see "We can change the world!" # FeatureContext::assertPageContainsText()
    Then I follow "Register"                     # FeatureContext::clickLink()

1 scenario (1 passed)
3 steps (3 passed)

Problem is the Test Works but the chrome browser is not launched. What am I doing wrong?

Upvotes: 3

Views: 12264

Answers (1)

Igor Lantushenko
Igor Lantushenko

Reputation: 1791

You should add @javascript tag before scenario, because by default behat is using goutte session which is not using selenium webdriver. More about Goutte driver

@javascript
Scenario: Visit homepage

Or in behat.yml set the default session to selenium2

extensions:
    Behat\MinkExtension\Extension:
      default_session: selenium2

But after that behat will launch firefox browser, for launching especially chrome - you should add browser_name: chrome option

extensions:
    Behat\MinkExtension\Extension:
      browser_name: chrome

And also you should specify wd_host params for the selenium2 config param

extensions:
    Behat\MinkExtension\Extension:
      selenium2:
            wd_host: "http://127.0.0.1:4444/wd/hub"

Upvotes: 4

Related Questions