Skip to content

← All questions

Recorded spec is all .btn_primary and nth-child — fix the locators before or after converting?

Asked 11,930 views3 answers

Recorded a checkout. The spec is mostly this:

ts
await page.locator('.inventory_item:nth-child(3) > .pricebar > .btn_primary').click();
await page.locator('#checkout').click();

Each of those came back with a // sdods:fragile comment above it, and the CLI finished with

text
⚠ 12 CSS/XPath locator(s) marked // sdods:fragile — prefer role/label/test-id locators.

I would rather not convert this into a feature and inherit twelve selectors that break next sprint. What is the right order of operations?

asked by Nikhil Sane487 ·

3 answers

Know the answer?

Reviewed before it appears. Wrap commands and output in triple backticks and they will render as a code block.

Have a different question? Ask it.

Related