Skip to content

Commit

Permalink
#590: Checkbox manipulation in regions
Browse files Browse the repository at this point in the history
  • Loading branch information
xurizaemon committed Jul 3, 2021
1 parent 40af5f3 commit 2013c78
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions features/blackbox.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Feature: Test DrupalContext
Scenario: Submit a form in a region
Given I am on the homepage
When I fill in "Search…" with "Views" in the "navigation" region
And I check "extra" in the "navigation" region
And I press "Search" in the "navigation" region
Then I should see the text "Search again" in the "right sidebar" region

Expand Down
1 change: 1 addition & 0 deletions fixtures/blackbox/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ <h1 id="site-name">Drupal</h1>
<form action="form.html">
<label for="search">Search&hellip;</label>
<input id="search" name="search" type="text"/>
<input type="checkbox" name="extra" value="1" id="extra"><label for="extra">extra</label>
<input type="submit" value="Search"/>
</form>
</div>
Expand Down
40 changes: 39 additions & 1 deletion src/Drupal/DrupalExtension/Context/MinkContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public function assertRegionLinkFollow($link, $region)
}

/**
* Checks, if a button with id|name|title|alt|value exists or not and pressess the same
* Checks if a button with id|name|title|alt|value exists or not and presses the same
*
* @Given I press :button in the :region( region)
*
Expand Down Expand Up @@ -442,6 +442,44 @@ public function regionFillField($field, $value, $region)
$regionObj->fillField($field, $value);
}

/**
* Checks if a checkbox with id|name|title|alt|value exists or not and checks the same
*
* @Given I check :locator in the :region( region)
*
* @param $locator
* string The id|name|title|alt|value of the checkbox to be checked
* @param $region
* string The region in which the checkbox should be checked
*
* @throws \Exception
* If region or checkbox within it cannot be found.
*/
public function assertRegionCheckBox($locator, $region)
{
$regionObj = $this->getRegion($region);
$regionObj->checkField($locator);
}

/**
* Checks if a checkbox with id|name|title|alt|value exists or not and unchecks the same
*
* @Given I uncheck :checkbox in the :region( region)
*
* @param $locator
* string The id|name|title|alt|value of the checkbox to be unchecked
* @param $region
* string The region in which the checkbox should be unchecked
*
* @throws \Exception
* If region or checkbox within it cannot be found.
*/
public function assertRegionUncheckBox($locator, $region)
{
$regionObj = $this->getRegion($region);
$regionObj->uncheckField($locator);
}

/**
* Find a heading in a specific region.
*
Expand Down

0 comments on commit 2013c78

Please sign in to comment.