diff --git a/features/blackbox.feature b/features/blackbox.feature index 06246470..d9d8fbe2 100644 --- a/features/blackbox.feature +++ b/features/blackbox.feature @@ -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 diff --git a/fixtures/blackbox/index.html b/fixtures/blackbox/index.html index d50b7dba..d3585059 100644 --- a/fixtures/blackbox/index.html +++ b/fixtures/blackbox/index.html @@ -10,6 +10,7 @@

Drupal

+
diff --git a/src/Drupal/DrupalExtension/Context/MinkContext.php b/src/Drupal/DrupalExtension/Context/MinkContext.php index e2ac026f..00508680 100644 --- a/src/Drupal/DrupalExtension/Context/MinkContext.php +++ b/src/Drupal/DrupalExtension/Context/MinkContext.php @@ -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) * @@ -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. *