Symfony2 Selenium Behat base_url not loaded

I am setting up a testing env for an application in symfony2 but I get some errors that I don't find a coherent answer online...

composer json

"require-dev": {   ...   "behat/symfony2-extension": "^2.1",   "behat/mink-browserkit-driver": "^1.3",   "behat/mink-goutte-driver": "@stable",   "behat/mink-extension": "@stable",   "behat/mink-selenium2-driver": "^1.3" }, 

behat.yml - old one

default:     extensions:         Behat\MinkExtension:             base_url: 'http://myapp.lan/app_test.php/'             browser_name: firefox             default_session: selenium2             goutte: ~             selenium2: ~             javascript_session: selenium2          Behat\Symfony2Extension: ~ 

behat.yml - new one

default:     extensions:         Behat\Symfony2Extension: ~          Behat\MinkExtension:             base_url: http://myapp.lan/app_test.php/             browser_name: firefox             sessions:                 goutte:                     goutte: ~                 selenium2:                     selenium2: ~                 symfony2:                     symfony2: ~             javascript_session: selenium2     suites:         site:             type: symfony_bundle             bundle: SiteBundle             mink_session: symfony2             contexts:                 - MyApp\SiteBundle\Features\Context\FeatureContext 

feature

Feature: Test login of users    @javascript   Scenario: Login to application     Given: I am on "/"       Then I should see "Login" 

I am using

  • selenium/selenium-server-standalone-2.50.1.jar.
  • Firefox 44 installed in my OS (Linux Mint)

The browser starts but there no url triggered.

Symfony2 Selenium Behat base_url not loaded

As you see the url input is empty and after few seconds the browser closes with the test failing.

When i run echo $this->getSession()->getCurrentUrl(); I get about:blank so obviously base_url is ignored.

If i enter the url manually then everything is OK.

I don't have a VM or something else installed just a linux box with latest version of firefox/chrome and latest version of selenium which is also my dev environment.

Replay

I can confirm that this example worked for me. Got it from Installing behat3 with composer.json

composer.json

{
    "require-dev": {
        "behat/behat" : "3.0.15",
        "behat/symfony2-extension" : "2.0.0",
        "behat/mink": "1.6.1",
        "behat/mink-extension": "2.0.1",
        "behat/mink-browserkit-driver": "1.2.0",
        "behat/mink-goutte-driver": "1.1.0",
        "behat/mink-selenium2-driver": "1.2.0"
    }
}

behat.yml

default:
    extensions:
        Behat\Symfony2Extension: ~
        Behat\MinkExtension:
            base_url: http://myapp.lan/app_test.php
            browser_name: firefox
            sessions:
                goutte:
                    goutte: ~
                selenium2:
                    selenium2: ~
                symfony2:
                    symfony2: ~
    suites:
        backend:
            type: symfony_bundle
            bundle: ApplicationBackendBundle #Change this with your
            mink_session: symfony2
            contexts:
                - Application\BackendBundle\Features\Context\FeatureContext: #Change this with your
                    param1: hello
                    param2: world

FeatureContext

namespace Application\BackendBundle\Features\Context;

use Behat\MinkExtension\Context\MinkContext;

class FeatureContext extends MinkContext
{
    private $param1;
    private $param2;

    public function __construct($param1, $param2)
    {
        $this->param1 = $param1;
        $this->param2 = $param2;
    }
}

Gherkin

Feature: Visit pages and see contents

  Scenario: I visit home page and see welcome message
    Given I am on "/"
    Then I should see "Welcome to Application!"

  Scenario: I visit contact page and see contact message
    Given I am on "/contact"
    Then I should see "Contact me!"

ADDITION

Selenium and Firefox have compatibility issues that I myself experienced before. If you Google, you'll see similar posts. Try in this order:

  1. Try selenium-server-standalone-2.43.1.jar version. https://selenium-release.storage.googleapis.com/index.html?path=2.43/
  2. Try Chrome browser by using chromedriver. Running selenium server standalone and chromedriver

You should really go through http://www.inanzzz.com/index.php/posts/behat for examples.

Category: java Time: 2016-01-31 Views: 1

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.250 (s). 12 q(s)