Chapters
23 Chapters
|
1:59:49
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: >=5.4.0, <7.3.0
Subscribe to download the code!Compatible PHP versions: >=5.4.0, <7.3.0
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
10.
Mink Session inside FeatureContext
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This tutorial uses a very old version of Symfony. The fundamentals of Behat are still valid, but integration with Symfony will be different.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=5.4.0, <7.3.0",
"symfony/symfony": "^2.7", // v2.7.4
"twig/twig": "^1.22", // v1.22.1
"sensio/framework-extra-bundle": "^3.0", // v3.0.16
"doctrine/doctrine-bundle": "^1.5", // v1.5.1
"doctrine/orm": "^2.5", // v2.5.1
"doctrine/doctrine-fixtures-bundle": "^2.2", // v2.2.1
"behat/symfony2-extension": "^2.0" // v2.0.0
},
"require-dev": {
"behat/mink-extension": "^2.0", // v2.0.1
"behat/mink-goutte-driver": "^1.1", // v1.1.0
"behat/mink-selenium2-driver": "^1.2", // v1.2.0
"phpunit/phpunit": "^4.8" // 4.8.18
}
}
4 Comments
When i use MinkContext (Behat\MinkExtension\Context\MinkContext;) instead of RawMinkContext it works for me otherwise I get
FeatureContext has missing steps. Define them with these snippets:
/**
* @Given I am on :arg1
*/
public function iAmOn($arg1)
{
throw new PendingException();
}
/**
* @Then I should see :arg1
*/
public function iShouldSee($arg1)
{
throw new PendingException();
}
Hey Sumeet!
Actually, this makes *perfect* sense, and it illustrates the (only) difference between MinkContext and RawMinkContext:
A) RawMinkContext gives you access to the Mink session (via $this->getSession())
B) MinkContext also gives you access to the Mink session (via $this->getSession()). AND, it gives you a big list of built-in definitions (like Given I am on *, and Then I should see *).
If you look at MinkContext (https://github.com/Behat/Mi... you'll see that it extends RawMinkContext and then also adds a bunch of these "definitions".
In our tutorial, we use RawMinkContext... but in the next chapter (https://knpuniversity.com/s... we tell Behat to load *our* FeatureContext file and ALSO MinkContext. There's not really any big advantage of doing it this way (versus making your FeatureContext extend MinkContext), it's just 2 different ways of importing the definitions from MinkContext.
I hope that helps!
Cheers!
What do I do if there are 2 duplicate buttons on the page in different areas. How can I choose one over the other.
Hey Lindsay!
GREAT question - it's one of the trickiest things, but ultimately has an easy solution. First, there's basically an example here: https://knpuniversity.com/s.... Basically, the trick is to use CSS. You could use CSS to select the specific button, but I usually just use CSS to select some wrapper element that is unique to only *one* of the buttons. THEN, I call pressButton('Button Name') on that element.
I hope that helps!
"Houston: no signs of life"
Start the conversation!