cypress dynamique selector

Created on 23 Sep 2020  路  2Comments  路  Source: cypress-io/cypress

Hi,

i'm working in a projet wich contients dynamique selector

as you can see after each refresh the name of the class be changed.

**cy.get(".MuiToolbar-root-201 > :nth-child(1) > div > .MuiButtonBase-root-252 > .MuiButton-label-227 > .MuiSvgIcon-root-255").click();

cy.get(".MuiToolbar-root-504 > :nth-child(1) > div > .MuiButtonBase-root-555 > .MuiButton-label-530 > .MuiSvgIcon-root-558")**

question

Most helpful comment

Read our guide to selecting elements https://on.cypress.io/best-practices#Selecting-Elements

All 2 comments

set data tags data-cypress="my-element" instead of accessing through classes. That way your spec files are cleaner too

Read our guide to selecting elements https://on.cypress.io/best-practices#Selecting-Elements

Was this page helpful?
0 / 5 - 0 ratings

Related issues

igorpavlov picture igorpavlov  路  3Comments

zbigniewkalinowski picture zbigniewkalinowski  路  3Comments

brian-mann picture brian-mann  路  3Comments

jennifer-shehane picture jennifer-shehane  路  3Comments

szabyg picture szabyg  路  3Comments