EzDevInfo.com

Mink

PHP 5.3+ web browser emulator abstraction Welcome to the Mink documentation! — Mink 1.6 documentation

Struggling to install mink and behat using composer for use with symfony2

I'm trying to install behat and mink with symfony 2.4 using composer but I can't seem to get my composer.json file to an resolve to an installable set of packages.

I installed symfony2 using the command on http://symfony.com/doc/current/book/installation.html

php composer.phar create-project symfony/framework-standard-edition /path/to/webroot/Symfony 2.4.*

Below is my require section of my composer.json file:

"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "~2.4",
    "doctrine/orm": "~2.2,>=2.2.3",
    "doctrine/doctrine-bundle": "~1.2",
    "twig/extensions": "~1.0",
    "symfony/assetic-bundle": "~2.3",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~2.3",
    "sensio/framework-extra-bundle": "~3.0",
    "sensio/generator-bundle": "~2.3",
    "incenteev/composer-parameter-handler": "~2.0",
    "behat/behat":  "2.4.*@stable",
    "behat/mink":   "1.4.*@stable",
    "behat/symfony2-extension":      "*",
    "behat/mink-extension":          "*",
    "behat/mink-browserkit-driver":  "*",
    "behat/mink-selenium2-driver":   "*"
}

I get the following message on the screen after running composer update:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Conclusion: remove symfony/symfony v2.4.0
- behat/mink v1.4.0 requires symfony/css-selector >=2.0.0,<2.2.0-dev -> satisfiable by symfony/symfony[2.0.7, v2.0.10, v2.0.11, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.0.21, v2.0.22, v2.0.23, v2.0.24, v2.0.25, v2.0.9, v2.1.0, v2.1.1, v2.1.10, v2.1.11, v2.1.12, v2.1.13, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9], symfony/css-selector[2.0.4, 2.0.5, 2.0.6, 2.0.7, v2.0.10, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.0.21, v2.0.22, v2.0.23, v2.0.24, v2.0.25, v2.0.9, v2.1.0, v2.1.1, v2.1.10, v2.1.11, v2.1.12, v2.1.13, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9].
- behat/mink v1.4.1 requires symfony/css-selector >=2.0,<2.3-dev -> satisfiable by symfony/symfony[2.0.7, v2.0.10, v2.0.11, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.0.21, v2.0.22, v2.0.23, v2.0.24, v2.0.25, v2.0.9, v2.1.0, v2.1.1, v2.1.10, v2.1.11, v2.1.12, v2.1.13, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9, v2.2.0, v2.2.1, v2.2.10, v2.2.11, v2.2.2, v2.2.3, v2.2.4, v2.2.5, v2.2.6, v2.2.7, v2.2.8, v2.2.9], symfony/css-selector[2.0.4, 2.0.5, 2.0.6, 2.0.7, v2.0.10, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.0.21, v2.0.22, v2.0.23, v2.0.24, v2.0.25, v2.0.9, v2.1.0, v2.1.1, v2.1.10, v2.1.11, v2.1.12, v2.1.13, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9, v2.2.0, v2.2.1, v2.2.10, v2.2.11, v2.2.2, v2.2.3, v2.2.4, v2.2.5, v2.2.6, v2.2.7, v2.2.8, v2.2.9].
- behat/mink v1.4.2 requires symfony/css-selector >=2.0,<2.3-dev -> satisfiable by symfony/symfony[2.0.7, v2.0.10, v2.0.11, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.0.21, v2.0.22, v2.0.23, v2.0.24, v2.0.25, v2.0.9, v2.1.0, v2.1.1, v2.1.10, v2.1.11, v2.1.12, v2.1.13, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9, v2.2.0, v2.2.1, v2.2.10, v2.2.11, v2.2.2, v2.2.3, v2.2.4, v2.2.5, v2.2.6, v2.2.7, v2.2.8, v2.2.9], symfony/css-selector[2.0.4, 2.0.5, 2.0.6, 2.0.7, v2.0.10, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.0.21, v2.0.22, v2.0.23, v2.0.24, v2.0.25, v2.0.9, v2.1.0, v2.1.1, v2.1.10, v2.1.11, v2.1.12, v2.1.13, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9, v2.2.0, v2.2.1, v2.2.10, v2.2.11, v2.2.2, v2.2.3, v2.2.4, v2.2.5, v2.2.6, v2.2.7, v2.2.8, v2.2.9].
- behat/mink v1.4.3 requires symfony/css-selector >=2.0,<2.4-dev -> satisfiable by symfony/symfony[2.0.7, v2.0.10, v2.0.11, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.0.21, v2.0.22, v2.0.23, v2.0.24, v2.0.25, v2.0.9, v2.1.0, v2.1.1, v2.1.10, v2.1.11, v2.1.12, v2.1.13, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9, v2.2.0, v2.2.1, v2.2.10, v2.2.11, v2.2.2, v2.2.3, v2.2.4, v2.2.5, v2.2.6, v2.2.7, v2.2.8, v2.2.9, v2.3.0, v2.3.1, v2.3.2, v2.3.3, v2.3.4, v2.3.5, v2.3.6, v2.3.7, v2.3.8], symfony/css-selector[2.0.4, 2.0.5, 2.0.6, 2.0.7, v2.0.10, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.0.21, v2.0.22, v2.0.23, v2.0.24, v2.0.25, v2.0.9, v2.1.0, v2.1.1, v2.1.10, v2.1.11, v2.1.12, v2.1.13, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9, v2.2.0, v2.2.1, v2.2.10, v2.2.11, v2.2.2, v2.2.3, v2.2.4, v2.2.5, v2.2.6, v2.2.7, v2.2.8, v2.2.9, v2.3.0, v2.3.1, v2.3.2, v2.3.3, v2.3.4, v2.3.5, v2.3.6, v2.3.7, v2.3.8].
- Can only install one of: symfony/symfony[v2.4.0, v2.3.0].
- Can only install one of: symfony/symfony[v2.4.0, v2.3.1].
- Can only install one of: symfony/symfony[v2.4.0, v2.3.2].
- Can only install one of: symfony/symfony[v2.4.0, v2.3.3].
- Can only install one of: symfony/symfony[v2.4.0, v2.3.4].
- Can only install one of: symfony/symfony[v2.4.0, v2.3.5].
- Can only install one of: symfony/symfony[v2.4.0, v2.3.6].
- Can only install one of: symfony/symfony[v2.4.0, v2.3.7].
- Can only install one of: symfony/symfony[v2.4.0, v2.3.8].
- Can only install one of: symfony/symfony[v2.4.0, v2.2.0].
- Can only install one of: symfony/symfony[v2.4.0, v2.2.1].
- Can only install one of: symfony/symfony[v2.4.0, v2.2.10].
- Can only install one of: symfony/symfony[v2.4.0, v2.2.11].
- Can only install one of: symfony/symfony[v2.4.0, v2.2.2].
- Can only install one of: symfony/symfony[v2.4.0, v2.2.3].
- Can only install one of: symfony/symfony[v2.4.0, v2.2.4].
- Can only install one of: symfony/symfony[v2.4.0, v2.2.5].
- Can only install one of: symfony/symfony[v2.4.0, v2.2.6].
- Can only install one of: symfony/symfony[v2.4.0, v2.2.7].
- Can only install one of: symfony/symfony[v2.4.0, v2.2.8].
- Can only install one of: symfony/symfony[v2.4.0, v2.2.9].
- Can only install one of: symfony/symfony[v2.4.0, v2.1.0].
- Can only install one of: symfony/symfony[v2.4.0, v2.1.1].
- Can only install one of: symfony/symfony[v2.4.0, v2.1.10].
- Can only install one of: symfony/symfony[v2.4.0, v2.1.11].
- Can only install one of: symfony/symfony[v2.4.0, v2.1.12].
- Can only install one of: symfony/symfony[v2.4.0, v2.1.13].
- Can only install one of: symfony/symfony[v2.4.0, v2.1.2].
- Can only install one of: symfony/symfony[v2.4.0, v2.1.3].
- Can only install one of: symfony/symfony[v2.4.0, v2.1.4].
- Can only install one of: symfony/symfony[v2.4.0, v2.1.5].
- Can only install one of: symfony/symfony[v2.4.0, v2.1.6].
- Can only install one of: symfony/symfony[v2.4.0, v2.1.7].
- Can only install one of: symfony/symfony[v2.4.0, v2.1.8].
- Can only install one of: symfony/symfony[v2.4.0, v2.1.9].
- Can only install one of: symfony/symfony[v2.4.0, 2.0.7].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.10].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.11].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.12].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.13].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.14].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.15].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.16].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.17].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.18].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.19].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.20].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.21].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.22].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.23].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.24].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.25].
- Can only install one of: symfony/symfony[v2.4.0, v2.0.9].
- don't install symfony/css-selector 2.0.4|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector 2.0.5|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector 2.0.6|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector 2.0.7|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.0.10|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.0.12|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.0.13|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.0.14|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.0.15|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.0.16|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.0.17|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.0.18|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.0.19|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.0.20|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.0.21|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.0.22|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.0.23|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.0.24|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.0.25|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.0.9|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.1.0|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.1.1|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.1.10|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.1.11|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.1.12|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.1.13|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.1.2|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.1.3|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.1.4|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.1.5|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.1.6|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.1.7|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.1.8|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.1.9|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.2.0|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.2.1|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.2.10|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.2.11|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.2.2|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.2.3|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.2.4|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.2.5|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.2.6|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.2.7|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.2.8|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.2.9|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.3.0|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.3.1|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.3.2|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.3.3|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.3.4|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.3.5|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.3.6|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.3.7|don't install symfony/symfony v2.4.0
- don't install symfony/css-selector v2.3.8|don't install symfony/symfony v2.4.0
- Installation request for symfony/symfony ~2.4 -> satisfiable by symfony/symfony[v2.4.0].
- Installation request for behat/mink 1.4.*@stable -> satisfiable by behat/mink[v1.4.0, v1.4.1, v1.4.2, v1.4.3].

I just looking to get these to get these componants installed so I can mess around with BDD

Thanks for any help with this


Source: (StackOverflow)

How do I tell Behat / Mink to hover over an element on a webpage?

I am new to Behat. I am currently using the Mink Extension and the Selenium2 driver and I would like to know how to specify that the test should hover over an element as part of the Scenario.

For example, here is my scenario:

Scenario: Testing that the Contact Us submenu appears
    Given I am on "/"
    When I hover over "About"
    Then I should see "Contact Us"

Source: (StackOverflow)

Advertisements

Mink: wait for page to load in @BeforeStep

I want to execute some javascript on page in @BeforeStep hook that depends on jQuery. However jQuery is not defined at that time, in fact page is blank.

Here's what I am trying to achive:

/**
 * @BeforeStep @javascript
 */
public function registerAjaxEventHandlers()
{
    $javascript = <<<JS
        window.jQuery(document).ready(function () {
            if (window.__ajaxStatus !== undefined) {
                return;
            }
            window.__ajaxStatus = 'none';

            $('body').ajaxStop(function() {
              window.__ajaxStatus = 'idle';
            });

            $('body').ajaxStart(function() {
              window.__ajaxStatus = 'in-flight';
            });
        });
JS;
        //$this->getSession()->wait(5000, 'window.jQuery !== undefined');
        $this->getSession()->executeScript($javascript);
    }

I figured maybe I could wait for the page to load jQuery first (commented line), but it is not true. Seems like execution is halted until that hook is processed.

What is the right place in behat/mink ecosystem to execute javascript on page?


Source: (StackOverflow)

Testing multi-tenancy Laravel applications using Behat / Mink and Behat Laravel Extension

I am building a multi-tenant SaaS application which I am trying to write tests for with Behat, using Mink and the Behat Laravel Extension

When you register for an account, you get your own subdomain on the site {account}.tenancy.dev

my behat.yml file looks like so:

default:
    extensions:
        Laracasts\Behat:
            # env_path: .env.behat
        Behat\MinkExtension:
            default_session: laravel
            base_url: http://tenancy.dev
            laravel: ~

I am having problems straight off the bat as when I try to test my registration flow, I am getting a 404 error testing that the new subdomain is accessible, all of the data has been saved correctly, manually testing the process works and the subdomain routing works.

I was wondering if there was any way to do this using Behat and how I would go about setting Behat / Mink to use wildcard subdomains to test SaaS applications?

I am running the test inside the Homestead VM.


Source: (StackOverflow)

How to handle confirm popup with phantomjs + behat + mink

In my tests I use this step to confirm a javascript confirm popup:

/**
 * @when /^(?:|I )confirm the popup$/
 */
public function confirmPopup()
{
    $this->getSession()->getDriver()->getWebDriverSession()->accept_alert();
}

This step work fine with selenium2 and chrome/firefox, but doesn't work with phantomjs.

How can I handle a confirm popup with phantomjs ?

for informations:

  • symfony: 2.0.23
  • behat: 2.4.6
  • mink: 1.5.0
  • Symfony2Extension: 1.0.2
  • MinkExtension: 1.1.4
  • MinkBrowserKitDriver: 1.1.0
  • MinkSelenium2Driver: 1.1.0
  • phamtomjs 1.9.1

behat.yml

default:
    extensions:
        Behat\Symfony2Extension\Extension:
            mink_driver: true
        Behat\MinkExtension\Extension:
            base_url: "http://localhost:8000/app_test.php"
            default_session: selenium2
            selenium2:
                wd_host: "http://localhost:9876/wd/hub"

Thanks!


Source: (StackOverflow)

Can I send raw keyboard input using Mink and Selenium2?

I am using Behat and Mink with the Selenium2 driver, and I'm trying to type directly into a form field (simulating raw keyboard input), instead of using the fillField() function.

This is what I'm trying:

$element = $this->getSession()->getPage()->find('css', '#questionName');
$element->focus();

$element->keyPress('a');

// also tried this, with no success
// $element->keyDown('a');
// $element->keyUp('a');

There is an <input type="text" id="questionName"> element on the page. It correctly receives the focus, but does not respond to any of the simulated keyboard input.

Is it possible to simulate raw keyboard input like this?
What am I doing wrong?


Source: (StackOverflow)

Blocking a package install in PHP Composer to use a fork of the package

I am working with Behat and Composer for a project at work. I had to create a fork and patch for Mink and the Mink Selenium 2 driver to handle popup windows. Currently the patches are still being reviewed by those that manage the repos I forked. So in the mean time I would like to use my fork versions instead.

I have added my repositories to composer and they are being pulled in. However the "behat/mink" package is still being installed because the "behat/mink-extension" requires it. The thing is it can use my fork of it too. So I would like to have it pull in only mine and not the "behat/mink" package.

Can I do this? Can I block a package's required package in favor of my fork?

Thanks!


Source: (StackOverflow)

Behat Mink webdriver session is destroyed after every feature in a suite

I am trying to automate sugarcrm functionality with behat BDD and Mink with selenium webdriver for php. I have properly installed both of them and able to run behat and mink together. for example checking login on sugarcrm as one feature.

Now the problem is when i create two feature file say login.feature and setup.feature. Behat successfully automate login process in browser but as soon as it switches to setup.feature which require login session to be maintained from previous feature, it destroy session and comes back to login window. therefore, second feature test is always failing.

How i can maintain session for every feature in my feature suite?

Just to tell you guys that i have also tried them in a single feature file as different scenario but with no luck as the same thing is haapening

Please Help me if anyone knows about it.


Source: (StackOverflow)

Trying To Set Up Selenium + Behat On Mac

So I got Behat working fine with the headless browser, however I wanted to use Selenium 2 to test some JavaScript heavy pages.

When I run vendor/bin/behat, I get this error on the first scenario marked with @javascript:

Curl error thrown for http POST to http://localhost:4444/wd/hub/session with params: {"desiredCapabilities":{"browserName":"firefox","version":"8","platform":"ANY","browserVersion":"8","browser":"firefox","name":"Behat test","deviceOrientation":"portrait","deviceType":"tablet","selenium-version":"2.31.0","max-duration":300},"requiredCapabilities":[]}

      couldn't connect to host

I don't know why it's connecting to a wrong port when I defined 443 in my config file. And why does it say device type is table? Here is my behat.yml:

default:
  paths:
    features: tests/functional/features
    bootstrap: tests/functional/features/bootstrap
  extensions:
    Behat\MinkExtension\Extension:
      base_url: http://myvirtualhost.com
      goutte: ~
      selenium2: ~
  context:
    parameters:
      wd_host: 127.0.0.1:4443/wd/hub
      wd_capabilities: { "browser": "firefox", "version": "21"}

I have Selenium 2 running at 127.0.0.1:4443/wd/hub properly.

I have Firefox version 21 installed.

This is my composer.json, I have the Selenium 2 driver:

{
    "name": "my-website",
    "description": "My Website",
    "minimum-stability": "dev",
    "require": {
        "php": ">=5.3",
        "zendframework/zendframework": "2.1.5",
        "doctrine/common": "dev-master#d7987c96675e153638729383577090feed9854f1"
    },
    "require-dev": {
        "phpunit/phpunit": "3.7.x-dev#19f1d742e0c36150001062f592c93f80aef3a9fd",
        "behat/behat": "dev-develop#1f1bead31e96da5e30fd5d499d5cf66d29b68cf6",
        "behat/mink": "v1.4.3",
        "behat/mink-extension": "dev-master#ef2c8639ebc254f0ff6e555b7834700caf5db9c4",
        "behat/mink-goutte-driver": "dev-master#v1.0.8",
        "behat/mink-selenium2-driver": "v1.0.6"
    }
}

Source: (StackOverflow)

This page is asking you to confirm that you want to leave

I am running the behat tests on my site installation. I am getting the following errors when running the tests. I switched into using firefox, because I had issues with the new chromedriver 2.10. Can I work around this one?

Error message:

Modal dialog present: This page is asking you to confirm that you want to leave - data you have entered may not be saved.

Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'jesus-ProLiant-MicroServer', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-32-generic', java.version: '1.6.0_32'

Session ID: 2d072ef8-60e8-494b-b389-96e954041fb0
Driver info: org.openqa.selenium.firefox.FirefoxDriver

Capabilities [{platform=LINUX, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=31.0, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, nativeEvents=false, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]

Source: (StackOverflow)

Maintaining the the session between scenarios in a single feature file in behat and mink

I have done a lot of R&D on this but i am unable to find a solution.

I need to maintain a login session between different scenarios in a single feature file. I have made a function I am logged in and I have written in background. so at the start of every scenario the login happens. but what i want is to maintain a single login session across the scenarios. Can anyone suggest.?

example Code is :

Feature: To test the output

Background:
  Given I am logged in 

@javascript
 Scenario: To test the positive input
   When I fill in "test" with "aab"
   And I press "add"
   Then I should see "welcome"

@javascript
  Scenario:To test the negative inputs
    When I fill in "test" with "@#$@!!111"
    And I press "add"
    Then I should see "Sorry,invalid input please try again"

Now if another person reviews my code he would come to know about the positive and negative test cases. but every time the scenarios are reloaded,what if i have 50 scenarios in a feature. for bigger projects. it doesnt look good at every scenario i log in and i waste extra 15 minutes in total.what i want is after every scenario in a single feature file, the test continues with the same login session.


Source: (StackOverflow)

Behat Mink Remember Me Test

I am trying to test the "remember me" feature using Behat/Mink. Here's my scenario:

Scenario: A user logs in ticking "Remember me". As he closes his browser and visits back the site, he should be automatically logged in
  Given I am on "/login"
  Then I should see "Site Login"
  When I fill in "Username" with "test"
  And I fill in "Password" with "test"
  And I check "Remember me"
  When I press "Login"
  Then I should see "Welcome"
  When I restart the browser
  Then I go to "/login"
  Then I should see "Welcome"

Here's the definition for restarting the browser:

/**
 * @When /^I restart the browser$/
 */
public function iRestartTheBrowser()
{
    $this->getSession()->restart();
}

I have also tried $this->getSession()->reset();

The problem is since the cookies are deleted upon browser restart, the "remember me" feature no longer works. Is there any way of doing a restart in mink without clearing the cookies?


Source: (StackOverflow)

Behat on Windows - taking screenshots

I've got several Behat tests that take screenshots using something similar to this:

$driver->getWebDriverSession()->screenshot();

Does anyone know of a Behat plugin or extension that can compare two screenshots? And it must work on Windows.


Source: (StackOverflow)

how can i set timeout for page loading in Mink with Selenium 2 driver?

My application uses Mink with Selenium 2 driver. when i try to load the page with some resources that are loading slow (or not loading at all) the application waits infinitely until everything is loaded.

for i have several hundreds of iterations in my application - you can imagine how long the script is executed.

question: is there any possibility to set a timeout for page to load? and throw some exception if the page is not loaded during that period?

thanks in advance!


Source: (StackOverflow)

Behat/Mink with Selenium 2 throws "Could not open connection"

I've started writing Acceptance Tests with Behat, Mink Extension, Selenium 2 and Symfony. I've followed the instructions, which can be seen here: http://extensions.behat.org/mink/

If i want to start my first feature with "./bin/behat" it says:

christian@christian-VirtualBox:/var/www/wiglee$ ./bin/behat 
Feature: User Registration
  In order to use ProjectNameHere
  As a user
  I should be able to register

  @javascript
  Scenario: User Registration                 # features/user.registration.feature:7
    Given I register as "test@test.com" # InheritedFeatureContext::registerAs()
      Could not open connection
    And I logout                              # InheritedFeatureContext::logout()

1 scenario (1 failed)
2 steps (1 skipped, 1 failed)

I started the selenium server, and the output tells me the connection should be okay:

INFO: Got a request to create a new session: {platform=ANY, browserVersion=8, browserName=firefox, deviceType=tablet, name=Behat test, selenium-version=2.31.0, browser=firefox, deviceOrientation=portrait, version=8, max-duration=300}

How i started Selenium Hub:

java -jar ./selenium-server-standalone-2.39.0.jar -role hub

How i added a Selenium Node (without the '.' between local and host):

java -jar ./selenium-server-standalone-2.39.0.jar -role node -hub http://local.host:4444/grid/register

Here is my behat.yml:

default:
  context:
    parameters:
      browser: firefox
    class:  'InheritedFeatureContext'
  extensions:
    SensioLabs\Behat\PageObjectExtension\Extension: ~
    Behat\MinkExtension\Extension:
      base_url:  'http://localhost/nameofproject/web/app_dev.php'
      selenium2: ~
      default_session: 'selenium2'

# No context:
no_context:
  paths:
    bootstrap: 'NON_EXISTING_FOLDER'
  filters:
    tags:      '~@javascript'

# Context based on inheritance:
inheritance:
  context:
    class:      'InheritedFeatureContext'

# Context based on traits:
traits:
  paths:
    bootstrap:  'features/php54_bootstrap'
  context:
    class:      'TraitedFeatureContext'

# Context based on subcontexting:
subcontexts:
  context:
    class:      'SubcontextedFeatureContext'

Here is the verbose output:

Given I register as "test@test.com" # InheritedFeatureContext::registerAs()
      exception 'WebDriver\Exception\UnknownError' with message 'Error forwarding the new session Empty pool of VM for setup {platform=ANY, browserVersion=8, browserName=firefox, deviceType=tablet, name=Behat test, selenium-version=2.31.0, browser=firefox, deviceOrientation=portrait, version=8, max-duration=300}' in vendor/instaclick/php-webdriver/lib/WebDriver/Exception.php:157
      Stack trace:
      #0 vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php(140): WebDriver\Exception::factory(13, 'Error forwardin...')
      #1 vendor/instaclick/php-webdriver/lib/WebDriver/WebDriver.php(76): WebDriver\AbstractWebDriver->curl('POST', '/session', Array, Array)
      #2 vendor/behat/mink-selenium2-driver/src/Behat/Mink/Driver/Selenium2Driver.php(260): WebDriver\WebDriver->session('firefox', Array)
      #3 vendor/behat/mink/src/Behat/Mink/Session.php(62): Behat\Mink\Driver\Selenium2Driver->start()
      #4 vendor/behat/mink/src/Behat/Mink/Mink.php(114): Behat\Mink\Session->start()
      #5 vendor/sensiolabs/behat-page-object-extension/src/SensioLabs/Behat/PageObjectExtension/Context/PageFactory.php(71): Behat\Mink\Mink->getSession()
      #6 vendor/sensiolabs/behat-page-object-extension/src/SensioLabs/Behat/PageObjectExtension/Context/PageObjectContext.php(27): SensioLabs\Behat\PageObjectExtension\Context\PageFactory->createPage('Registration')
      #7 features/bootstrap/InheritedFeatureContext.php(27): SensioLabs\Behat\PageObjectExtension\Context\PageObjectContext->getPage('Registration')
      #8 [internal function]: InheritedFeatureContext->registerAs('cbergau86@gmail...')
      #9 vendor/behat/behat/src/Behat/Behat/Definition/Annotation/Definition.php(155): call_user_func_array(Array, Array)
      #10 vendor/behat/behat/src/Behat/Behat/Tester/StepTester.php(157): Behat\Behat\Definition\Annotation\Definition->run(Object(InheritedFeatureContext))
      #11 vendor/behat/behat/src/Behat/Behat/Tester/StepTester.php(126): Behat\Behat\Tester\StepTester->executeStepDefinition(Object(Behat\Gherkin\Node\StepNode), Object(Behat\Behat\Definition\Annotation\Given))
      #12 vendor/behat/behat/src/Behat/Behat/Tester/StepTester.php(95): Behat\Behat\Tester\StepTester->executeStep(Object(Behat\Gherkin\Node\StepNode))
      #13 vendor/behat/gherkin/src/Behat/Gherkin/Node/AbstractNode.php(42): Behat\Behat\Tester\StepTester->visit(Object(Behat\Gherkin\Node\StepNode))
      #14 vendor/behat/behat/src/Behat/Behat/Tester/ScenarioTester.php(148): Behat\Gherkin\Node\AbstractNode->accept(Object(Behat\Behat\Tester\StepTester))
      #15 vendor/behat/behat/src/Behat/Behat/Tester/ScenarioTester.php(87): Behat\Behat\Tester\ScenarioTester->visitStep(Object(Behat\Gherkin\Node\StepNode), Object(Behat\Gherkin\Node\ScenarioNode), Object(InheritedFeatureContext), Array, false)
      #16 vendor/behat/gherkin/src/Behat/Gherkin/Node/AbstractNode.php(42): Behat\Behat\Tester\ScenarioTester->visit(Object(Behat\Gherkin\Node\ScenarioNode))
      #17 vendor/behat/behat/src/Behat/Behat/Tester/FeatureTester.php(88): Behat\Gherkin\Node\AbstractNode->accept(Object(Behat\Behat\Tester\ScenarioTester))
      #18 vendor/behat/gherkin/src/Behat/Gherkin/Node/AbstractNode.php(42): Behat\Behat\Tester\FeatureTester->visit(Object(Behat\Gherkin\Node\FeatureNode))
      #19 vendor/behat/behat/src/Behat/Behat/Console/Command/BehatCommand.php(150): Behat\Gherkin\Node\AbstractNode->accept(Object(Behat\Behat\Tester\FeatureTester))
      #20 vendor/behat/behat/src/Behat/Behat/Console/Command/BehatCommand.php(128): Behat\Behat\Console\Command\BehatCommand->runFeatures(Object(Behat\Gherkin\Gherkin))
      #21 vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php(241): Behat\Behat\Console\Command\BehatCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #22 vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(881): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #23 vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(191): Symfony\Component\Console\Application->doRunCommand(Object(Behat\Behat\Console\Command\BehatCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #24 vendor/behat/behat/src/Behat/Behat/Console/BehatApplication.php(68): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #25 vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(121): Behat\Behat\Console\BehatApplication->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #26 vendor/behat/behat/bin/behat(32): Symfony\Component\Console\Application->run()
      #27 {main}

      Next exception 'Behat\Mink\Exception\DriverException' with message 'Could not open connection' in vendor/behat/mink-selenium2-driver/src/Behat/Mink/Driver/Selenium2Driver.php:262
      Stack trace:
      #0 vendor/behat/mink/src/Behat/Mink/Session.php(62): Behat\Mink\Driver\Selenium2Driver->start()
      #1 vendor/behat/mink/src/Behat/Mink/Mink.php(114): Behat\Mink\Session->start()
      #2 vendor/sensiolabs/behat-page-object-extension/src/SensioLabs/Behat/PageObjectExtension/Context/PageFactory.php(71): Behat\Mink\Mink->getSession()
      #3 vendor/sensiolabs/behat-page-object-extension/src/SensioLabs/Behat/PageObjectExtension/Context/PageObjectContext.php(27): SensioLabs\Behat\PageObjectExtension\Context\PageFactory->createPage('Registration')
      #4 features/bootstrap/InheritedFeatureContext.php(27): SensioLabs\Behat\PageObjectExtension\Context\PageObjectContext->getPage('Registration')
      #5 [internal function]: InheritedFeatureContext->registerAs('cbergau86@gmail...')
      #6 vendor/behat/behat/src/Behat/Behat/Definition/Annotation/Definition.php(155): call_user_func_array(Array, Array)
      #7 vendor/behat/behat/src/Behat/Behat/Tester/StepTester.php(157): Behat\Behat\Definition\Annotation\Definition->run(Object(InheritedFeatureContext))
      #8 vendor/behat/behat/src/Behat/Behat/Tester/StepTester.php(126): Behat\Behat\Tester\StepTester->executeStepDefinition(Object(Behat\Gherkin\Node\StepNode), Object(Behat\Behat\Definition\Annotation\Given))
      #9 vendor/behat/behat/src/Behat/Behat/Tester/StepTester.php(95): Behat\Behat\Tester\StepTester->executeStep(Object(Behat\Gherkin\Node\StepNode))
      #10 vendor/behat/gherkin/src/Behat/Gherkin/Node/AbstractNode.php(42): Behat\Behat\Tester\StepTester->visit(Object(Behat\Gherkin\Node\StepNode))
      #11 vendor/behat/behat/src/Behat/Behat/Tester/ScenarioTester.php(148): Behat\Gherkin\Node\AbstractNode->accept(Object(Behat\Behat\Tester\StepTester))
      #12 vendor/behat/behat/src/Behat/Behat/Tester/ScenarioTester.php(87): Behat\Behat\Tester\ScenarioTester->visitStep(Object(Behat\Gherkin\Node\StepNode), Object(Behat\Gherkin\Node\ScenarioNode), Object(InheritedFeatureContext), Array, false)
      #13 vendor/behat/gherkin/src/Behat/Gherkin/Node/AbstractNode.php(42): Behat\Behat\Tester\ScenarioTester->visit(Object(Behat\Gherkin\Node\ScenarioNode))
      #14 vendor/behat/behat/src/Behat/Behat/Tester/FeatureTester.php(88): Behat\Gherkin\Node\AbstractNode->accept(Object(Behat\Behat\Tester\ScenarioTester))
      #15 vendor/behat/gherkin/src/Behat/Gherkin/Node/AbstractNode.php(42): Behat\Behat\Tester\FeatureTester->visit(Object(Behat\Gherkin\Node\FeatureNode))
      #16 vendor/behat/behat/src/Behat/Behat/Console/Command/BehatCommand.php(150): Behat\Gherkin\Node\AbstractNode->accept(Object(Behat\Behat\Tester\FeatureTester))
      #17 vendor/behat/behat/src/Behat/Behat/Console/Command/BehatCommand.php(128): Behat\Behat\Console\Command\BehatCommand->runFeatures(Object(Behat\Gherkin\Gherkin))
      #18 vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php(241): Behat\Behat\Console\Command\BehatCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #19 vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(881): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #20 vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(191): Symfony\Component\Console\Application->doRunCommand(Object(Behat\Behat\Console\Command\BehatCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #21 vendor/behat/behat/src/Behat/Behat/Console/BehatApplication.php(68): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #22 vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(121): Behat\Behat\Console\BehatApplication->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #23 vendor/behat/behat/bin/behat(32): Symfony\Component\Console\Application->run()
      #24 {main}

Here is my composer.json:

"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "2.4.*",
    "doctrine/orm": ">=2.2.3,<2.4-dev",
    "doctrine/doctrine-bundle": "1.2.*",
    "twig/extensions": "1.0.*",
    "symfony/assetic-bundle": "2.3.*",
    "symfony/swiftmailer-bundle": "2.3.*",
    "symfony/monolog-bundle": "2.3.*",
    "sensio/distribution-bundle": "2.3.*",
    "sensio/framework-extra-bundle": "2.3.*",
    "sensio/generator-bundle": "2.3.*",
    "incenteev/composer-parameter-handler": "~2.0",
    "friendsofsymfony/rest-bundle": "dev-master",
    "friendsofsymfony/user-bundle": "~2.0@dev",
    "jms/serializer-bundle": "dev-master",
    "behat/symfony2-extension": "*",
    "behat/mink-extension": "*",
    "behat/mink-browserkit-driver": "*",
    "behat/mink-selenium2-driver": "*",
    "behat/mink-goutte-driver": "*",
    "phpunit/phpunit": "3.7.*",
    "sensiolabs/behat-page-object-extension": "*",
    "jms/i18n-routing-bundle": "1.1.0",
    "knplabs/knp-menu-bundle": "v1.1.2",
    "friendsofsymfony/message-bundle": "dev-master"
},

Source: (StackOverflow)