Skip to content

Commit

Permalink
add checkbox name attrbitute support
Browse files Browse the repository at this point in the history
  • Loading branch information
gimler committed Dec 19, 2016
1 parent 486eb01 commit 17b1db9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Codeception/Module/WebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ protected function findCheckable($context, $radioOrCheckbox, $byValue = false)
} else {
$xpath = Locator::combine(
// @codingStandardsIgnoreStart
"//input[@type = 'checkbox' or @type = 'radio'][(@id = //label[contains(normalize-space(string(.)), $locator)]/@for) or @placeholder = $locator]",
"//input[@type = 'checkbox' or @type = 'radio'][(@id = //label[contains(normalize-space(string(.)), $locator)]/@for) or @placeholder = $locator or @name = $locator]",
// @codingStandardsIgnoreEnd
"//label[contains(normalize-space(string(.)), $locator)]//input[@type = 'radio' or @type = 'checkbox']"
);
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/Codeception/Module/TestsForWeb.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ public function testCheckboxByCss()
$this->assertEquals('agree', $form['terms']);
}

public function testCheckboxByName()
{
$this->module->amOnPage('/form/checkbox');
$this->module->checkOption('terms');
$this->module->click('Submit');
$form = data::get('form');
$this->assertEquals('agree', $form['terms']);
}

public function testCheckboxByLabel()
{
$this->module->amOnPage('/form/checkbox');
Expand Down

0 comments on commit 17b1db9

Please sign in to comment.