How to adjust Playwright Codegen's locating priority/strategy in an Angular project with third-party component libraries?

461 Views Asked by At
  • 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?

0

There are 0 best solutions below