Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
NamedSelector wasn’t matching buttons by name attribute in `link_or…
Browse files Browse the repository at this point in the history
…_button` selector
  • Loading branch information
Alexander Obuhovich authored and stof committed May 18, 2014
1 parent f68dac7 commit a81005b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 6 additions & 3 deletions src/Behat/Mink/Selector/NamedSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,19 @@ class NamedSelector implements SelectorInterface
[./@href][(%linkMatch% or %imgAltMatch%)]
|
.//input
[%buttonTypeFilter%][(%idOrValueMatch% or %titleMatch%)]
[%buttonTypeFilter%][(%buttonMatch%)]
|
.//input
[./@type = 'image'][%altMatch%]
|
.//button
[(%idOrValueMatch% or %titleMatch% or %tagTextMatch%)]
[(%buttonMatch% or %tagTextMatch%)]
|
.//*
[./@role = 'link'][(%idOrValueMatch% or %titleMatch% or %tagTextMatch%)]
|
.//*
[(./@role = 'button' or ./@role = 'link')][(%idOrValueMatch% or %titleMatch% or %tagTextMatch%)]
[./@role = 'button'][(%buttonMatch% or %tagTextMatch%)]
XPATH

,'content' => <<<XPATH
Expand Down
8 changes: 2 additions & 6 deletions tests/Selector/NamedSelectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ public function getSelectorTests()
'link_or_button (with-href)' => array('test.html', 'link_or_button', 'link-text', 5, 9),
'link_or_button (without-href) ignored' => array('test.html', 'link_or_button', 'bad-link-text', 0),
'link_or_button* (role=link)' => array('test.html', 'link_or_button', 'link-role-text', 4, 7),

// bug in selector: 17 instead of 25 and 34 instead of 42, because 8 buttons with `name` attribute were not matched
'link_or_button (input, name/value/title)' => array('test.html', 'link_or_button', 'button-text', 17, 34),
'link_or_button (input, name/value/title)' => array('test.html', 'link_or_button', 'button-text', 25, 42),
'link_or_button (type=image, with-alt)' => array('test.html', 'link_or_button', 'button-alt-text', 1, 2),
'link_or_button (input type=submit, with-id)' => array('test.html', 'link_or_button', 'input-submit-button', 1),
'link_or_button (input type=image, with-id)' => array('test.html', 'link_or_button', 'input-image-button', 1),
Expand All @@ -106,9 +104,7 @@ public function getSelectorTests()
'link_or_button (button type=image, with-id)' => array('test.html', 'link_or_button', 'button-image-button', 1),
'link_or_button (button type=button, with-id)' => array('test.html', 'link_or_button', 'button-button-button', 1),
'link_or_button (button type=reset, with-id)' => array('test.html', 'link_or_button', 'button-reset-button', 1),

// bug in selector: 8 instead of 12 and 16 instead of 20, because 4 buttons with `name` attribute were not matched
'link_or_button* (role=button, name/value/title)' => array('test.html', 'link_or_button', 'button-role-text', 8, 16),
'link_or_button* (role=button, name/value/title)' => array('test.html', 'link_or_button', 'button-role-text', 12, 20),
'link_or_button* (role=button type=submit, with-id)' => array('test.html', 'link_or_button', 'role-button-submit-button', 1),
'link_or_button* (role=button type=image, with-id)' => array('test.html', 'link_or_button', 'role-button-image-button', 1),
'link_or_button* (role=button type=button, with-id)' => array('test.html', 'link_or_button', 'role-button-button-button', 1),
Expand Down

0 comments on commit a81005b

Please sign in to comment.