/**
* Copyright 2018 Google Inc. All rights reserved.
* Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { it, expect } from './fixtures';
it('query', async ({page}) => {
await page.setContent(`
yo
ya
\nye
`);
expect(await page.$eval(`text=ya`, e => e.outerHTML)).toBe('
ya
');
expect(await page.$eval(`text="ya"`, e => e.outerHTML)).toBe('
ya
');
expect(await page.$eval(`text=/^[ay]+$/`, e => e.outerHTML)).toBe('
ya
');
expect(await page.$eval(`text=/Ya/i`, e => e.outerHTML)).toBe('
ya
');
expect(await page.$eval(`text=ye`, e => e.outerHTML)).toBe('
\nye
');
await page.setContent(`
ye
ye
`);
expect(await page.$eval(`text="ye"`, e => e.outerHTML)).toBe('
ye
');
await page.setContent(`
yo
"ya
hello world!
`);
expect(await page.$eval(`text="\\"ya"`, e => e.outerHTML)).toBe('
"ya
');
expect(await page.$eval(`text=/hello/`, e => e.outerHTML)).toBe('
hello world!
');
expect(await page.$eval(`text=/^\\s*heLLo/i`, e => e.outerHTML)).toBe('
hello world!
');
await page.setContent(`
yo
ya
hey
hey
`);
expect(await page.$eval(`text=hey`, e => e.outerHTML)).toBe('
yo
ya
hey
hey
');
expect(await page.$eval(`text="yo">>text="ya"`, e => e.outerHTML)).toBe('
ya
');
expect(await page.$eval(`text='yo'>> text="ya"`, e => e.outerHTML)).toBe('
ya
');
expect(await page.$eval(`text="yo" >>text='ya'`, e => e.outerHTML)).toBe('
ya
');
expect(await page.$eval(`text='yo' >> text='ya'`, e => e.outerHTML)).toBe('
ya
');
expect(await page.$eval(`'yo'>>"ya"`, e => e.outerHTML)).toBe('
ya
');
expect(await page.$eval(`"yo" >> 'ya'`, e => e.outerHTML)).toBe('
ya
');
await page.setContent(`
yo
yo
`);
expect(await page.$$eval(`text=yo`, es => es.map(e => e.outerHTML).join('\n'))).toBe('
yo
\n
yo
');
await page.setContent(`
'
"
\\
x
`);
expect(await page.$eval(`text='\\''`, e => e.outerHTML)).toBe('
\'
');
expect(await page.$eval(`text='"'`, e => e.outerHTML)).toBe('
"
');
expect(await page.$eval(`text="\\""`, e => e.outerHTML)).toBe('
"
');
expect(await page.$eval(`text="'"`, e => e.outerHTML)).toBe('
\'
');
expect(await page.$eval(`text="\\x"`, e => e.outerHTML)).toBe('
x
');
expect(await page.$eval(`text='\\x'`, e => e.outerHTML)).toBe('
x
');
expect(await page.$eval(`text='\\\\'`, e => e.outerHTML)).toBe('
\\
');
expect(await page.$eval(`text="\\\\"`, e => e.outerHTML)).toBe('
\\
');
expect(await page.$eval(`text="`, e => e.outerHTML)).toBe('
"
');
expect(await page.$eval(`text='`, e => e.outerHTML)).toBe('
\'
');
expect(await page.$eval(`"x"`, e => e.outerHTML)).toBe('
x
');
expect(await page.$eval(`'x'`, e => e.outerHTML)).toBe('