Home > other >  Cypress doesn't find original ids of HTML
Cypress doesn't find original ids of HTML

Time:10-14

I have a problem with cypress. I have an HTML where elements have their own ids containing numbers in increasing order (1009, 1010...). The problem is that when I pass these indices to the test, it cannot find the elements. Inspecting the window of cypress of my website, the ids contain different numbers, that's why Cypress cannot see them, but I don't understand why. Has someone an idea about that? I cannot share the code because it is for work, but i hope I've been clear enough.

CodePudding user response:

Without code it's very difficult but it sounds to me like you have dynamic ids so try using selectors that will pick the elements despite the ids changing every time your test runs.

It's recommended (when you can) to ask the devs to have a dedicated attribute to avoid this kind of stuff happening but when you can't, there are other ways.

Here's a link to cypress best practices to select elements and isolate them

https://docs.cypress.io/guides/references/best-practices#Selecting-Elements

  • Related