Skip to content

← All questions

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

Example threads. These questions and answers were written by the SDODS team to document real problems and how to fix them. The people named are illustrative, not real users. Questions asked on this site are marked new.

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?

3 answers

Know the answer?

Wrap commands and output in triple backticks and they will render as a code block.

Checking whether you’re signed in…

Have a different question? Ask it.

Related