I have a function, contains the page objects
class TemplateListPage:
def __init__(self, page):
self.list_first_row = self.page.locator(".grid-row").first
self.use_btn = self.page.locator(".useTemplate")
And I would like to chain the button with the first row in assertion, in the spec test. Like
expect(TemplateListPage().list_first_row.use_btn).to_have_count(0)
or
TemplateListPage().list_first_row.use_btn.click()
But got an error:
AttributeError: 'Locator' object has no attribute 'use_btn'
Is there any way that I can chain the page object locators in the test?
Playwright recently added the and_ locator, which should allow you to achieve what your aiming for: