File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -143,9 +143,21 @@ public function waitFor($timeout, $callback)
143143 */
144144 public function find ($ selector , $ locator )
145145 {
146- $ items = $ this ->findAll ($ selector , $ locator );
146+ if ('named ' === $ selector ) {
147+ $ item = $ this ->find ('named_exact ' , $ locator );
148+ if (null === $ item ) {
149+ $ item = $ this ->find ('named_partial ' , $ locator );
150+ }
151+
152+ return $ item ;
153+ }
154+
155+ $ xpath = $ this ->selectorsHandler ->selectorToXpath ($ selector , $ locator );
156+ $ xpathFirst = '( ' . $ xpath . ')[1] ' ;
157+
158+ $ items = $ this ->findAll ('xpath ' , $ xpathFirst );
147159
148- return count ($ items ) ? current ($ items ) : null ;
160+ return count ($ items ) > 0 ? reset ($ items ) : null ;
149161 }
150162
151163 /**
@@ -155,7 +167,7 @@ public function findAll($selector, $locator)
155167 {
156168 if ('named ' === $ selector ) {
157169 $ items = $ this ->findAll ('named_exact ' , $ locator );
158- if (empty ($ items )) {
170+ if (count ($ items ) === 0 ) {
159171 $ items = $ this ->findAll ('named_partial ' , $ locator );
160172 }
161173
You can’t perform that action at this time.
0 commit comments