Playwright - What is the meaning of page.locator('article')

100 Views Asked by At

By reading the Playwright documentation https://playwright.dev/docs/pom, I find these lines of code:

page.locator('article div.markdown ul > li > a');

expect(page.locator('article')).toContainText('Page Object Model is a common pattern');

When I examine the source of the web pages, I can't find anything related to 'article'. There is no custom tag named article, or CSS class named article

Can anybody explain to me the meaning of page.locator('article') ?

1

There are 1 best solutions below

0
On

It's a CSS selector for a standard HTML element, <article>.

Any CSS selector that has no special syntax like a . or # prefix is simply an HTML tag. page.locator("p") selects <p> elements by tag name, and page.locator("article") selects <article> elements by tag name.