@@ -103,19 +103,19 @@ it('should work', async ({page}) => {
103
103
expect ( ( await page . $$ ( `text="Sign in"` ) ) . length ) . toBe ( 1 ) ;
104
104
expect ( await page . $eval ( `text=lo wo` , e => e . outerHTML ) ) . toBe ( '<span>Hello\n \nworld</span>' ) ;
105
105
expect ( await page . $eval ( `text="Hello world"` , e => e . outerHTML ) ) . toBe ( '<span>Hello\n \nworld</span>' ) ;
106
- expect ( await page . $ ( `text="lo wo"` ) ) . toBe ( null ) ;
106
+ expect ( await page . $eval ( `text="lo wo"` , e => e . outerHTML ) ) . toBe ( '<span>Hello\n \nworld</span>' ) ;
107
107
expect ( ( await page . $$ ( `text=lo \nwo` ) ) . length ) . toBe ( 1 ) ;
108
- expect ( ( await page . $$ ( `text="lo wo "` ) ) . length ) . toBe ( 0 ) ;
108
+ expect ( ( await page . $$ ( `text="lo \nwo "` ) ) . length ) . toBe ( 1 ) ;
109
109
} ) ;
110
110
111
111
it ( 'should work with :text' , async ( { page} ) => {
112
112
await page . setContent ( `<div>yo</div><div>ya</div><div>\nHELLO \n world </div>` ) ;
113
113
expect ( await page . $eval ( `:text("ya")` , e => e . outerHTML ) ) . toBe ( '<div>ya</div>' ) ;
114
114
expect ( await page . $eval ( `:text-is("ya")` , e => e . outerHTML ) ) . toBe ( '<div>ya</div>' ) ;
115
115
expect ( await page . $eval ( `:text("y")` , e => e . outerHTML ) ) . toBe ( '<div>yo</div>' ) ;
116
- expect ( await page . $ ( `:text-is("y ")` ) ) . toBe ( null ) ;
116
+ expect ( await page . $ ( `:text-is("Y ")` ) ) . toBe ( null ) ;
117
117
expect ( await page . $eval ( `:text("hello world")` , e => e . outerHTML ) ) . toBe ( '<div>\nHELLO \n world </div>' ) ;
118
- expect ( await page . $eval ( `:text-is("hello world")` , e => e . outerHTML ) ) . toBe ( '<div>\nHELLO \n world </div>' ) ;
118
+ expect ( await page . $eval ( `:text-is("HELLO world")` , e => e . outerHTML ) ) . toBe ( '<div>\nHELLO \n world </div>' ) ;
119
119
expect ( await page . $eval ( `:text("lo wo")` , e => e . outerHTML ) ) . toBe ( '<div>\nHELLO \n world </div>' ) ;
120
120
expect ( await page . $ ( `:text-is("lo wo")` ) ) . toBe ( null ) ;
121
121
expect ( await page . $eval ( `:text-matches("^[ay]+$")` , e => e . outerHTML ) ) . toBe ( '<div>ya</div>' ) ;
@@ -145,11 +145,11 @@ it('should work across nodes', async ({page}) => {
145
145
expect ( await page . $ ( `text=hello world` ) ) . toBe ( null ) ;
146
146
147
147
expect ( await page . $eval ( `:text-is("Hello, world!")` , e => e . id ) ) . toBe ( 'target1' ) ;
148
- expect ( await page . $ ( `:text-is("Hello")` ) ) . toBe ( null ) ;
148
+ expect ( await page . $eval ( `:text-is("Hello")` , e => e . id ) ) . toBe ( 'target1' ) ;
149
149
expect ( await page . $eval ( `:text-is("world")` , e => e . id ) ) . toBe ( 'target2' ) ;
150
150
expect ( await page . $$eval ( `:text-is("world")` , els => els . length ) ) . toBe ( 1 ) ;
151
151
expect ( await page . $eval ( `text="Hello, world!"` , e => e . id ) ) . toBe ( 'target1' ) ;
152
- expect ( await page . $ ( `text="Hello"` ) ) . toBe ( null ) ;
152
+ expect ( await page . $eval ( `text="Hello"` , e => e . id ) ) . toBe ( 'target1' ) ;
153
153
expect ( await page . $eval ( `text="world"` , e => e . id ) ) . toBe ( 'target2' ) ;
154
154
expect ( await page . $$eval ( `text="world"` , els => els . length ) ) . toBe ( 1 ) ;
155
155
@@ -162,6 +162,20 @@ it('should work across nodes', async ({page}) => {
162
162
expect ( await page . $$eval ( `text=/world/` , els => els . length ) ) . toBe ( 1 ) ;
163
163
} ) ;
164
164
165
+ it ( 'should work with text nodes in quoted mode' , async ( { page} ) => {
166
+ await page . setContent ( `<div id=target1>Hello<span id=target2>wo rld </span> Hi again </div>` ) ;
167
+ expect ( await page . $eval ( `text="Hello"` , e => e . id ) ) . toBe ( 'target1' ) ;
168
+ expect ( await page . $eval ( `text="Hi again"` , e => e . id ) ) . toBe ( 'target1' ) ;
169
+ expect ( await page . $eval ( `text="wo rld"` , e => e . id ) ) . toBe ( 'target2' ) ;
170
+ expect ( await page . $eval ( `text="Hellowo rld Hi again"` , e => e . id ) ) . toBe ( 'target1' ) ;
171
+ expect ( await page . $eval ( `text="Hellowo"` , e => e . id ) ) . toBe ( 'target1' ) ;
172
+ expect ( await page . $eval ( `text="Hellowo rld"` , e => e . id ) ) . toBe ( 'target1' ) ;
173
+ expect ( await page . $eval ( `text="wo rld Hi ag"` , e => e . id ) ) . toBe ( 'target1' ) ;
174
+ expect ( await page . $eval ( `text="again"` , e => e . id ) ) . toBe ( 'target1' ) ;
175
+ expect ( await page . $ ( `text="hi again"` ) ) . toBe ( null ) ;
176
+ expect ( await page . $eval ( `text=hi again` , e => e . id ) ) . toBe ( 'target1' ) ;
177
+ } ) ;
178
+
165
179
it ( 'should clear caches' , async ( { page} ) => {
166
180
await page . setContent ( `<div id=target1>text</div><div id=target2>text</div>` ) ;
167
181
const div = await page . $ ( '#target1' ) ;
@@ -277,10 +291,10 @@ it('should be case sensitive if quotes are specified', async ({page}) => {
277
291
expect ( await page . $ ( `text="yA"` ) ) . toBe ( null ) ;
278
292
} ) ;
279
293
280
- it ( 'should search for a substring without quotes ' , async ( { page} ) => {
294
+ it ( 'should search for a substring' , async ( { page} ) => {
281
295
await page . setContent ( `<div>textwithsubstring</div>` ) ;
282
296
expect ( await page . $eval ( `text=with` , e => e . outerHTML ) ) . toBe ( '<div>textwithsubstring</div>' ) ;
283
- expect ( await page . $ ( `text="with"` ) ) . toBe ( null ) ;
297
+ expect ( await page . $eval ( `text="with"` , e => e . outerHTML ) ) . toBe ( '<div>textwithsubstring</div>' ) ;
284
298
} ) ;
285
299
286
300
it ( 'should skip head, script and style' , async ( { page} ) => {
0 commit comments