Skip to content

Commit f5e56a4

Browse files
Alexander Obuhovichstof
authored andcommitted
NamedSelector wasn’t matching buttons by name attribute in link_or_button selector
1 parent 986367f commit f5e56a4

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/Selector/NamedSelector.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,19 @@ class NamedSelector implements SelectorInterface
9999
[./@href][(%linkMatch% or %imgAltMatch%)]
100100
|
101101
.//input
102-
[%buttonTypeFilter%][(%idOrValueMatch% or %titleMatch%)]
102+
[%buttonTypeFilter%][(%buttonMatch%)]
103103
|
104104
.//input
105105
[%lowercaseType% = 'image'][%altMatch%]
106106
|
107107
.//button
108-
[(%idOrValueMatch% or %titleMatch% or %tagTextMatch%)]
108+
[(%buttonMatch% or %tagTextMatch%)]
109+
|
110+
.//*
111+
[%lowercaseRole% = 'link'][(%idOrValueMatch% or %titleMatch% or %tagTextMatch%)]
109112
|
110113
.//*
111-
[(%lowercaseRole% = 'button' or %lowercaseRole% = 'link')][(%idOrValueMatch% or %titleMatch% or %tagTextMatch%)]
114+
[%lowercaseRole% = 'button'][(%buttonMatch% or %tagTextMatch%)]
112115
XPATH
113116

114117
,'content' => <<<XPATH

tests/Selector/NamedSelectorTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ public function getSelectorTests()
135135
'link_or_button (with-href)' => array('test.html', 'link_or_button', 'link-text', 5, 9),
136136
'link_or_button (without-href) ignored' => array('test.html', 'link_or_button', 'bad-link-text', 0),
137137
'link_or_button* (role=link)' => array('test.html', 'link_or_button', 'link-role-text', 4, 7),
138-
139-
// bug in selector: 17 instead of 25 and 34 instead of 42, because 8 buttons with `name` attribute were not matched
140-
'link_or_button (input, name/value/title)' => array('test.html', 'link_or_button', 'button-text', 17, 34),
138+
'link_or_button (input, name/value/title)' => array('test.html', 'link_or_button', 'button-text', 25, 42),
141139
'link_or_button (type=image, with-alt)' => array('test.html', 'link_or_button', 'button-alt-text', 1, 2),
142140
'link_or_button (input type=submit, with-id)' => array('test.html', 'link_or_button', 'input-submit-button', 1),
143141
'link_or_button (input type=image, with-id)' => array('test.html', 'link_or_button', 'input-image-button', 1),
@@ -147,9 +145,7 @@ public function getSelectorTests()
147145
'link_or_button (button type=image, with-id)' => array('test.html', 'link_or_button', 'button-image-button', 1),
148146
'link_or_button (button type=button, with-id)' => array('test.html', 'link_or_button', 'button-button-button', 1),
149147
'link_or_button (button type=reset, with-id)' => array('test.html', 'link_or_button', 'button-reset-button', 1),
150-
151-
// bug in selector: 8 instead of 12 and 16 instead of 20, because 4 buttons with `name` attribute were not matched
152-
'link_or_button* (role=button, name/value/title)' => array('test.html', 'link_or_button', 'button-role-text', 8, 16),
148+
'link_or_button* (role=button, name/value/title)' => array('test.html', 'link_or_button', 'button-role-text', 12, 20),
153149
'link_or_button* (role=button type=submit, with-id)' => array('test.html', 'link_or_button', 'role-button-submit-button', 1),
154150
'link_or_button* (role=button type=image, with-id)' => array('test.html', 'link_or_button', 'role-button-image-button', 1),
155151
'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)