2
  • This Angular project uses Emulated ViewEncapsulation, adds dynamically generated attributes like _ngcontent-xxx-c001 into most elements, which absolutely can't be used in E2E Test. Fortunately, Codegen does not seem to pick these attributes as locator either. ✅
  • We also use an internal component library which also generates dynamic id for elements like <div id="#xx_auto_id_1" ...>. However, in this case, Codegen has a strong preference for these attributes(id), which also leads to unstable tests. ❌

So I wonder if it is possible to modify Codegen's config so that it won't favor some locators like id? Otherwise is there a generator that better meets my needs? Selenium IDE? Or use Xpath?

  • You know that selectors don't only rely on their classes and ids right ? you can traverse an HTML tree with a lot of useful tools, such as `my-component > div + span:nth-child(3)` – MGX Mar 29 '23 at 09:01
  • @MGX That's not what they are asking. This is about playwright's codegen output. I just went looking for this and didn't find it. It would be nice to have a configurable preferred & exclusion list of locator strategies for codegen, for instance prefer `data-id` over classnames, or `aria-label` over text, or prefer to use classnames that start with `qa-` over others. – Alexandros V May 12 '23 at 16:55
  • Related issues: * https://github.com/microsoft/playwright/issues/5178 * https://github.com/microsoft/playwright/issues/19439 – Alexandros V May 12 '23 at 16:56

0 Answers0