Let us know what functionality you'd like to see in Playwright and what your use case is.
Let's say I have a page object like the one below
class PageObject {
readonly parent: Locator;
readonly child: Locator;
constructor(page: Page) {
this.parent = page.locator('[data-id=parent]');
this.child = page.locator('[data-id=child]');
}
}
It makes sense in my use case to have these as separate locators.
But in some instances I would essentially want to chain the parent locator to the child locator.
I could add another locator this.parentChild = page.locator('[data-id=parent] [data-id=child]') but it seems like duplication of selectors that are already defined.
Or I could extract out the selectors but that again is more code.
Some ideas are:
- Allow the first arg of page.locator() to be either a
selector: string OR a locator: Locator --> this.parent.locator(this.child)
- Be able to get the selector from a
locator --> this.parent.locator(this.child.selector)
Let us know what functionality you'd like to see in Playwright and what your use case is.
Let's say I have a page object like the one below
It makes sense in my use case to have these as separate locators.
But in some instances I would essentially want to chain the parent locator to the child locator.
I could add another locator
this.parentChild = page.locator('[data-id=parent] [data-id=child]')but it seems like duplication of selectors that are already defined.Or I could extract out the selectors but that again is more code.
Some ideas are:
selector: stringOR alocator: Locator-->this.parent.locator(this.child)locator-->this.parent.locator(this.child.selector)