Skip to content

Tinochkin/mink-extra-context

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mink Extra Context

Mink Extra Context provide additional contexts for behat/mink

Installation

This extension requires:

  • Behat 2.4+
  • Mink 1.4+
  • Mink extension

Through Composer

Step 1. Define dependencies in your composer.json:

{
    "require": {
        ...
        "weavora/mink-extra-context": "*"
    }
}

Step 2. Install/update your vendors:

    # install
    $ curl http://getcomposer.org/installer | php
    $ php composer.phar install

    # or update
    $ php composer.phar update

Step 3. Activate mink extra context extension by specifying its class in your behat.yml:

    # behat.yml
    default:
        # ...
        extensions:
            # ...
            Weavora\MinkExtra\Extension:
                form: true
                table: true
                page: true
                page_area: true

Step 4. Add MinkExtraContext to your FeatureContent

class FeatureContext extends \Behat\MinkExtension\Context\MinkContext
{

    public function __construct(array $parameters)
    {
        // ...
        $this->useContext('mink-extra', new \Weavora\MinkExtra\Context\MinkExtraContext());
    }
}

Page Context

Most common issue with browser session when element can't be found because page haven't loaded yet or ajax request is still processing. Page context allow you to stop worry about page loading time or ajax requests without hooking features with tons of wait statements.

What page context perform is inject special javascript page-wait conditions into every request related step (like click, go to and etc).

Form Context

Filling forms is often annoying task. Form context help you keep your form related features more structurized.

Usage examples:

Fill form

	Scenario: All form elements should be properly filled

		Given I am on "/tests/pages/form.php"
		When I fill form with:
			| Text				| text value			|
			| Checkbox			| YES					|
			| Select			| Option 2				|
			| Multiple Select	| MOption 2, MOption 3	|
			| Radio 2			| YES					|
			| Textarea			| textarea value		|
			| Checkbox Group	| Checkbox 1,Checkbox 3	|

		Then the "Text" field should contain "text value"
		And the "Checkbox" checkbox should be checked
		And the "Select" field should contain "2"
		And the "Multiple Select" multiple field should contain "2,3"
		And the "Radio 2" checkbox should be checked
		And the "Textarea" field should contain "textarea value"
		And the "Checkbox 1" checkbox should be checked
		And the "Checkbox 3" checkbox should be checked

Check form

	Scenario: All form elements should be properly asserted

		Given I am on "/tests/pages/form.php"
		When I fill in "Text" with "text value"
		And I check "Checkbox"
		And I select "Option 2" from "Select"
		And I select "MOption 1" from "Multiple Select"
		And I additionally select "MOption 2" from "Multiple Select"
		And I check "Radio 2"
		And I fill in "Textarea" with "textarea value"
		And I check "Checkbox 1"
		And I check "Checkbox 2"

		Then I should see form with:
			| Text				| text value			|
			| Checkbox			| YES					|
			| Select			| Option 2				|
			| Multiple Select	| MOption 1,MOption 2	|
			| Radio 2			| YES					|
			| Textarea			| textarea value		|
			| Checkbox Group	| Checkbox 1,Checkbox 2	|

Textareas

	Scenario: It should be possible put multiline value to textarea
		Given I am on "/tests/pages/form.php"

		When I fill in "Textarea" with:
		"""
		Line 1
		Line 2
		Line 3
		"""

		Then the "Textarea" field should contain:
		"""
		Line 1
		Line 2
		Line 3
		"""

Multiple select values asserts

	Scenario: Select field with multiple attribute should be properly asserted

		Given I am on "/form.php"
		When I select "MOption 1" from "Multiple Select"
		And I additionally select "MOption 3" from "Multiple Select"
		Then the "Multiple Select" multiple field should contain "1,3"

Notes

  1. Extension uses standard selectors to find fields. So you can use label selectors (like Title or Content) or name selectors (like post_form[title] or post_form[content])
  2. Extension support all field types like textarea, select, input and etc.

About

Additional context for behat/mink

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published