File tree Expand file tree Collapse file tree 3 files changed +27
-7
lines changed
Expand file tree Collapse file tree 3 files changed +27
-7
lines changed Original file line number Diff line number Diff line change 1010final class CssSelector implements Selector
1111{
1212 /** @var string */
13- private $ expression ;
13+ private $ expressionEncoded ;
1414
1515 public function __construct (string $ expression )
1616 {
17- $ this ->expression = $ expression ;
17+ $ this ->expressionEncoded = \json_encode (
18+ $ expression ,
19+ \JSON_UNESCAPED_SLASHES
20+ | \JSON_UNESCAPED_UNICODE
21+ | \JSON_THROW_ON_ERROR
22+ );
1823 }
1924
2025 public function expressionCount (): string
2126 {
22- return \sprintf ('document.querySelectorAll("%s").length ' , $ this ->expression );
27+ return \sprintf (
28+ 'document.querySelectorAll(%s).length ' ,
29+ $ this ->expressionEncoded
30+ );
2331 }
2432
2533 public function expressionFindOne (int $ position ): string
2634 {
27- return \sprintf ('document.querySelectorAll("%s")[%d] ' , $ this ->expression , $ position - 1 );
35+ return \sprintf (
36+ 'document.querySelectorAll(%s)[%d] ' ,
37+ $ this ->expressionEncoded ,
38+ $ position - 1
39+ );
2840 }
2941}
Original file line number Diff line number Diff line change 2121 */
2222class PageTest extends BaseTestCase
2323{
24- private const WAIT_FOR_ELEMENT_HTML = '<div data-name="el">content </div> ' ;
24+ private const WAIT_FOR_ELEMENT_HTML = '<div data-name="el">content1</div><div data-name=""el"">content2 </div> ' ;
2525 private const WAIT_FOR_ELEMENT_RESOURCE_FILE = 'elementLoad.html ' ;
2626
2727 public function testSetViewport (): void
@@ -441,7 +441,9 @@ public function testWaitUntilContainsElement(): void
441441
442442 self ::assertStringNotContainsString (self ::WAIT_FOR_ELEMENT_HTML , $ page ->getHtml ());
443443
444- $ page ->waitUntilContainsElement ('div[data-name=\"el\"] ' );
444+ $ page ->waitUntilContainsElement ('div[data-name="el"] ' ); // search for <div data-name="el">
445+ $ page ->waitUntilContainsElement ('div[data-name=el] ' ); // search for <div data-name="el">
446+ $ page ->waitUntilContainsElement ('div[data-name=\"el\"] ' ); // search for <div data-name=""el"'>
445447
446448 self ::assertStringContainsString (self ::WAIT_FOR_ELEMENT_HTML , $ page ->getHtml ());
447449 }
Original file line number Diff line number Diff line change @@ -11,9 +11,15 @@ <h1>page a</h1>
1111 let el = document . createElement ( 'div' ) ;
1212
1313 el . dataset . name = 'el' ;
14- el . innerHTML = 'content ' ;
14+ el . innerHTML = 'content1 ' ;
1515
1616 document . body . appendChild ( el )
17+
18+ let el2 = document . createElement ( 'div' ) ;
19+
20+ el2 . dataset . name = '"el"' ;
21+ el2 . innerHTML = 'content2' ;
22+ document . body . appendChild ( el2 )
1723 } , 500 )
1824</ script >
1925</ html >
You can’t perform that action at this time.
0 commit comments