Skip to content

Commit 83d1fcb

Browse files
Alexander Obuhovichstof
authored andcommitted
NamedSelector wasn’t matching buttons by name attribute in link_or_button selector
1 parent ceba322 commit 83d1fcb

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/Behat/Mink/Selector/NamedSelector.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,19 @@ class NamedSelector implements SelectorInterface
9393
[./@href][(%linkMatch% or %imgAltMatch%)]
9494
|
9595
.//input
96-
[%buttonTypeFilter%][(%idOrValueMatch% or %titleMatch%)]
96+
[%buttonTypeFilter%][(%buttonMatch%)]
9797
|
9898
.//input
9999
[%lowercaseType% = 'image'][%altMatch%]
100100
|
101101
.//button
102-
[(%idOrValueMatch% or %titleMatch% or %tagTextMatch%)]
102+
[(%buttonMatch% or %tagTextMatch%)]
103+
|
104+
.//*
105+
[%lowercaseRole% = 'link'][(%idOrValueMatch% or %titleMatch% or %tagTextMatch%)]
103106
|
104107
.//*
105-
[(%lowercaseRole% = 'button' or %lowercaseRole% = 'link')][(%idOrValueMatch% or %titleMatch% or %tagTextMatch%)]
108+
[%lowercaseRole% = 'button'][(%buttonMatch% or %tagTextMatch%)]
106109
XPATH
107110

108111
,'content' => <<<XPATH

tests/Selector/NamedSelectorTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ public function getSelectorTests()
9595
'link_or_button (with-href)' => array('test.html', 'link_or_button', 'link-text', 5, 9),
9696
'link_or_button (without-href) ignored' => array('test.html', 'link_or_button', 'bad-link-text', 0),
9797
'link_or_button* (role=link)' => array('test.html', 'link_or_button', 'link-role-text', 4, 7),
98-
99-
// bug in selector: 17 instead of 25 and 34 instead of 42, because 8 buttons with `name` attribute were not matched
100-
'link_or_button (input, name/value/title)' => array('test.html', 'link_or_button', 'button-text', 17, 34),
98+
'link_or_button (input, name/value/title)' => array('test.html', 'link_or_button', 'button-text', 25, 42),
10199
'link_or_button (type=image, with-alt)' => array('test.html', 'link_or_button', 'button-alt-text', 1, 2),
102100
'link_or_button (input type=submit, with-id)' => array('test.html', 'link_or_button', 'input-submit-button', 1),
103101
'link_or_button (input type=image, with-id)' => array('test.html', 'link_or_button', 'input-image-button', 1),
@@ -107,9 +105,7 @@ public function getSelectorTests()
107105
'link_or_button (button type=image, with-id)' => array('test.html', 'link_or_button', 'button-image-button', 1),
108106
'link_or_button (button type=button, with-id)' => array('test.html', 'link_or_button', 'button-button-button', 1),
109107
'link_or_button (button type=reset, with-id)' => array('test.html', 'link_or_button', 'button-reset-button', 1),
110-
111-
// bug in selector: 8 instead of 12 and 16 instead of 20, because 4 buttons with `name` attribute were not matched
112-
'link_or_button* (role=button, name/value/title)' => array('test.html', 'link_or_button', 'button-role-text', 8, 16),
108+
'link_or_button* (role=button, name/value/title)' => array('test.html', 'link_or_button', 'button-role-text', 12, 20),
113109
'link_or_button* (role=button type=submit, with-id)' => array('test.html', 'link_or_button', 'role-button-submit-button', 1),
114110
'link_or_button* (role=button type=image, with-id)' => array('test.html', 'link_or_button', 'role-button-image-button', 1),
115111
'link_or_button* (role=button type=button, with-id)' => array('test.html', 'link_or_button', 'role-button-button-button', 1),

0 commit comments

Comments
 (0)