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')
?
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, andpage.locator("article")
selects<article>
elements by tag name.