Questions tagged [behat]

Behat is a php framework for autotesting your business expectations. It's a Behavior Driven Development (BDD) framework for PHP, initially inspired by Ruby's Cucumber project. Now it's not only accepted as a PHP implementation of Cucumber, but it provides some quite unique features the original didn't have.

Behat is a php framework for autotesting your business expectations. It's a Behavior Driven Development (BDD) framework for PHP, initially inspired by Ruby's Cucumber project. Now it's not only accepted as a PHP implementation of Cucumber, but it provides some quite unique features the original didn't have.

1111 questions
5
votes
3 answers

How to set a request header in behat tests?

I am developing a Rest API and testing it with Behat and mink-selenium2-driver (for the first time) . For security purposes, every call needs to contain a apikey in the request header. My Problem is, i cannot set the header. My test looks like this:…
user3210460
  • 71
  • 2
  • 4
5
votes
2 answers

Behat 3 within symfony2.4 (doctrine access)

Situation I want to use BDD and Behat in my symfony projects from now on. Current project is sf2.4, and I strive to make Behat 3 work. I use the latest doc concerning behat3, as recommanded by jakub in this post. issue Behat 3 seems to work well.…
Wisebes
  • 475
  • 4
  • 14
5
votes
1 answer

Could not evaluate XPath (Behat/Mink)

I'm using the following function: /** * Click on the element with the provided xpath query * * @When /^I click on the element with xpath "([^"]*)"$/ */ public function iClickOnTheElementWithXPath($xpath) { $session =…
Ginz Its
  • 51
  • 1
  • 3
5
votes
2 answers

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…
Benjamin Lazarecki
  • 2,950
  • 1
  • 20
  • 27
5
votes
1 answer

Is it possible to use different step data depending on the current environment with Behat?

I am running into a bit of a conundrum. We have an antiquated system that I am writing Behat tests for. It works great for the most part. But I have noticed an issue where the Behat tests will fail if the data I am testing against the current…
5
votes
1 answer

When running a Behat login test through PhantomJS it only passes on the first run

I created a very simple login test in Behat to login to our internal application. There are two login types (done from the same screen and box). There is basic and advanced. The only difference is that in advanced the user that is logging in has…
Patrick
  • 3,302
  • 4
  • 28
  • 47
5
votes
2 answers

Behat and Symfony2 bundle issue?

I've got some problems with Behat (2.4.*@dev) init process inside Symfony2 bundle (ver 2.2.2). After command: bin/behat --init "@CompanyAppBundle" behat directories are created inside application root directory, not in bundle. The output is: +d…
mariuszgil
  • 49
  • 1
5
votes
2 answers

for each element with behat or codeception

I want to test a website which has a dynamic menustructure. I want to loop through all menuitems and run the same series of test on every page. We're talking about 100+ pages that change reguraly. I would like to do this with either behat or…
Jeroen
  • 317
  • 4
  • 8
5
votes
4 answers

How to switch to dynamically named iframe with Behat/Mink

Writing test for an iFrame generated when a button is clicked. The iFrame name and id are similar but generated dynamically. I have used "switchToiFrame" successfully before.
Ian Jenkins
  • 109
  • 2
  • 8
5
votes
2 answers

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…
Dziamid
  • 11,225
  • 12
  • 69
  • 104
5
votes
4 answers

Behat with Jenkins - how to serve PHP app?

I have recently started using Behat with Mink on a PHP project that uses the Slim microframework My Behat tests work fine but I would like to run them as part of my build, which uses the Jenkins-PHP template by Sebastian Bergmann. To do this, I…
gavD_UK
  • 395
  • 5
  • 11
4
votes
2 answers

Is there a way to have Behat NOT fail on PHP Notice errors?

I understand that it is a best practice to have all variables defined and to check for array indexes before evaluating. However, I'm trying to run some tests on new functionalities developed on top of some legacy code which has not been coded this…
JuanXarg
  • 428
  • 2
  • 11
4
votes
2 answers

How to test that Symfony Messenger events are dispatched in a multi bus scenario using Behat?

Seems difficult and there isn't much documentation around this (I'm using FirendsOfBehat Symfony extension). I want to test whether Transport carries any events by using get() method but I'm not getting any results. It feels like its not routing the…
db306
  • 934
  • 11
  • 22
4
votes
3 answers

Connecting Behat and Mink with Selenium and Chrome OR Safari OR Firefox on Mac

Edit: thanks to mykbas's answer, I got my system up and running! I've written a pretty thorough how-to for any Mac users that would like a step-by-step, including options for using Docker containers :) I've looked and looked, and I'm not finding…
Meg Claypool
  • 65
  • 1
  • 8
4
votes
4 answers

Undefined step reference in PhpStorm when using Codeception and Gherkin

I'd like to be able to use PhpStorm's "Go To Declaration" feature (Command + B on a Mac) in Gherkin feature files when using Codeception. However, PhpStorm doesn't seem to figure out where the steps are defined, and outputs this warning: Undefined…
Yngve Høiseth
  • 570
  • 6
  • 26