I am scraping data from a web page where the HTML source code shows a lot of "section" elements.... Is there a way to use Playwright locator to locate these elements and act on other contained HTML elements therein?
<section id="main"> <section class="master-form-container"> <section id="report" class="" role="form"> <section class="question-block instructions" question-type="instructions" data-index="0"> <h2 class="question" id="question0">360 Degree Feedback</h2>
This thread is trying to answer question "Is there a way to use Playwright locator to locate 'section' elements and interact with contained HTML elements?"
Yes, if you want to make your locators based on elements you should use CSS locator https://playwright.dev/docs/other-locators#css-locator
However, the recommendations are to use user-facing attributes i.e. getByRole
and other Testing Library-inspired syntax
See best practices
https://playwright.dev/docs/best-practices#use-locators
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].