Home > Blockchain >  Is it a good thing to use label / text to verify that element is found on the current page?
Is it a good thing to use label / text to verify that element is found on the current page?

Time:02-14

I'm new with robot framework so my qst is : in order to verify if a field exists on a page,is it good to use the field label for that :

${element_to_test}    //label[contains(text(),'test1, test2, test3')]

NB / I got this xpath by using chropath tool after selecting the target field thanks guys

CodePudding user response:

Not the best selector since the test will fail when the text changes. Best is to use a testid for interacting with elements.

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

(Written for Cypress, but locating strategies are basically the same between all frameworks)

  • Related