test: make sure asLocator works with has+hasText at the same time (#28937)

This commit is contained in:
Dmitry Gozman 2024-01-10 12:42:55 -08:00 committed by GitHub
parent 19a4f15eb6
commit 3851d9b897
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -356,6 +356,16 @@ it('reverse engineer hasNot', async ({ page }) => {
});
});
it('reverse engineer has + hasText', async ({ page }) => {
const locator = page.locator('section').filter({ hasText: 'foo', has: page.locator('div') }).locator('a');
expect.soft(generate(locator)).toEqual({
csharp: `Locator("section").Filter(new() { HasText = "foo" }).Filter(new() { Has = Locator("div") }).Locator("a")`,
java: `locator("section").filter(new Locator.FilterOptions().setHasText("foo")).filter(new Locator.FilterOptions().setHas(locator("div"))).locator("a")`,
javascript: `locator('section').filter({ hasText: 'foo' }).filter({ has: locator('div') }).locator('a')`,
python: `locator("section").filter(has_text="foo").filter(has=locator("div")).locator("a")`,
});
});
it('reverse engineer frameLocator', async ({ page }) => {
const locator = page
.frameLocator('iframe')