arrow-left Back to topicQuizExtensibilityCheck yourself1.Your team uses data-qa attributes for all test identifiers instead of data-testid. What's the simplest way to make page.getByTestId() work with data-qa?Register a custom selector engine that queries by data-qa attribute.Set testIdAttribute: 'data-qa' in playwright.config.ts use block — no custom engine needed.Use page.locator('[data-qa=...]') everywhere instead of getByTestId.Override getByTestId in a base test fixture to use a custom attribute.2.What two functions must a custom selector engine define?find() and findAll()select() and selectAll()query() and queryAll()match() and matchAll()3.Where must you register a custom selector engine in a Playwright Test setup, and why?In a beforeEach hook in each test file — to ensure registration before every test.In a worker-scoped auto-fixture — registration happens once per worker and registering the same name twice throws an error.In globalSetup — it runs once before all tests.In playwright.config.ts — the config accepts a selectorEngines array.4.What is the benefit of registering a custom engine with { contentScript: true }?The engine can access browser extension APIs.The engine runs in an isolated context protected from the page's JavaScript, preventing the app from interfering with the engine.The engine runs faster because it bypasses the DevTools Protocol.The engine is automatically applied to all frames in the page.5.After registering a custom engine named 'component', how do you use it in a locator?page.getByComponent('OrderForm')page.locator('component=OrderForm')page.selector('component', 'OrderForm')page.engine('component').find('OrderForm')6.When is building a custom selector engine actually warranted?Whenever you want faster element lookups than the built-in locators.When an internal component library uses a non-standard attribute scheme that none of the built-in locators can address — and testIdAttribute alone is not enough.Any time you use a CSS framework that generates unpredictable class names.For all projects — custom engines are the Playwright best practice for enterprise testing.7.Can you chain a custom selector engine locator with built-in locators?No — custom engine locators can only be used as standalone selectors.Yes — page.locator('component=OrderForm').getByLabel('Customer') finds a label within the component.Yes, but only with CSS selectors — not with semantic locators like getByRole.Only if the custom engine also implements queryAllChildren().8.Where in the code does the custom selector engine's query() function actually execute?In the Node.js test process — it receives element data via the DevTools Protocol.In the browser process — both query() and queryAll() run as browser-side JavaScript with full DOM access.In a shared worker thread between Node.js and the browser.In the Playwright service that runs alongside the test.Submit answersarrow-left PreviousClockService WorkersNext arrow-right