Skip to content

Commit

Permalink
feature: Add step to check and uncheck the checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
nmfzone committed Nov 18, 2019
1 parent a1468ce commit 89970c2
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/DuskContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,66 @@ public function selectRadio($selector, $value)
});
}

/**
* Checks checkbox field with specified selector.
*
* Example: When I check "animal"
* Example: And I check "animal"
*
* @When /^(?:|I )check "(?P<selector>(?:[^"]|\\")*)"$/
*/
public function selectCheckbox($selector)
{
$this->browse(function (Browser $browser) use ($selector) {
$browser->check($selector);
});
}

/**
* Unchecks checkbox field with specified selector.
*
* Example: When I uncheck "animal"
* Example: And I uncheck "animal"
*
* @When /^(?:|I )uncheck "(?P<selector>(?:[^"]|\\")*)"$/
*/
public function uncheckCheckbox($selector)
{
$this->browse(function (Browser $browser) use ($selector) {
$browser->uncheck($selector);
});
}

/**
* Checks checkbox field with specified selector & value.
*
* Example: When I check "animal" with value "Bats"
* Example: And I check "animal" with value "Bats"
*
* @When /^(?:|I )check "(?P<selector>(?:[^"]|\\")*)" with value "(?P<value>(?:[^"]|\\")*)"$/
*/
public function selectCheckboxWithValue($selector, $value)
{
$this->browse(function (Browser $browser) use ($selector, $value) {
$browser->check($selector, $value);
});
}

/**
* Unchecks checkbox field with specified selector & value.
*
* Example: When I uncheck "animal" with value "Bats"
* Example: And I uncheck "animal" with value "Bats"
*
* @When /^(?:|I )uncheck "(?P<selector>(?:[^"]|\\")*)" with value "(?P<value>(?:[^"]|\\")*)"$/
*/
public function uncheckCheckboxWithValue($selector, $value)
{
$this->browse(function (Browser $browser) use ($selector, $value) {
$browser->uncheck($selector, $value);
});
}

/**
* Attaches file to field with specified selector.
*
Expand Down

0 comments on commit 89970c2

Please sign in to comment.