');
- expect(await page.$eval(`:text-is("hello world")`, e => e.outerHTML)).toBe('
\nHELLO \n world
');
+ expect(await page.$eval(`:text-is("HELLO world")`, e => e.outerHTML)).toBe('
\nHELLO \n world
');
expect(await page.$eval(`:text("lo wo")`, e => e.outerHTML)).toBe('
\nHELLO \n world
');
expect(await page.$(`:text-is("lo wo")`)).toBe(null);
expect(await page.$eval(`:text-matches("^[ay]+$")`, e => e.outerHTML)).toBe('
ya
');
@@ -145,11 +145,11 @@ it('should work across nodes', async ({page}) => {
expect(await page.$(`text=hello world`)).toBe(null);
expect(await page.$eval(`:text-is("Hello, world!")`, e => e.id)).toBe('target1');
- expect(await page.$(`:text-is("Hello")`)).toBe(null);
+ expect(await page.$eval(`:text-is("Hello")`, e => e.id)).toBe('target1');
expect(await page.$eval(`:text-is("world")`, e => e.id)).toBe('target2');
expect(await page.$$eval(`:text-is("world")`, els => els.length)).toBe(1);
expect(await page.$eval(`text="Hello, world!"`, e => e.id)).toBe('target1');
- expect(await page.$(`text="Hello"`)).toBe(null);
+ expect(await page.$eval(`text="Hello"`, e => e.id)).toBe('target1');
expect(await page.$eval(`text="world"`, e => e.id)).toBe('target2');
expect(await page.$$eval(`text="world"`, els => els.length)).toBe(1);
@@ -162,6 +162,20 @@ it('should work across nodes', async ({page}) => {
expect(await page.$$eval(`text=/world/`, els => els.length)).toBe(1);
});
+it('should work with text nodes in quoted mode', async ({page}) => {
+ await page.setContent(`
Hellowo rld Hi again
`);
+ expect(await page.$eval(`text="Hello"`, e => e.id)).toBe('target1');
+ expect(await page.$eval(`text="Hi again"`, e => e.id)).toBe('target1');
+ expect(await page.$eval(`text="wo rld"`, e => e.id)).toBe('target2');
+ expect(await page.$eval(`text="Hellowo rld Hi again"`, e => e.id)).toBe('target1');
+ expect(await page.$eval(`text="Hellowo"`, e => e.id)).toBe('target1');
+ expect(await page.$eval(`text="Hellowo rld"`, e => e.id)).toBe('target1');
+ expect(await page.$eval(`text="wo rld Hi ag"`, e => e.id)).toBe('target1');
+ expect(await page.$eval(`text="again"`, e => e.id)).toBe('target1');
+ expect(await page.$(`text="hi again"`)).toBe(null);
+ expect(await page.$eval(`text=hi again`, e => e.id)).toBe('target1');
+});
+
it('should clear caches', async ({page}) => {
await page.setContent(`
text
text
`);
const div = await page.$('#target1');
@@ -277,10 +291,10 @@ it('should be case sensitive if quotes are specified', async ({page}) => {
expect(await page.$(`text="yA"`)).toBe(null);
});
-it('should search for a substring without quotes', async ({page}) => {
+it('should search for a substring', async ({page}) => {
await page.setContent(`
textwithsubstring
`);
expect(await page.$eval(`text=with`, e => e.outerHTML)).toBe('
textwithsubstring
');
- expect(await page.$(`text="with"`)).toBe(null);
+ expect(await page.$eval(`text="with"`, e => e.outerHTML)).toBe('