seleniumtestingautomationautomated-testsqwebelement

How to handle automatically generated web element (id)


I can't find element, because every time I refresh page, the element id is changed automatically

enter image description here

after refresh "input-19" is changed to any other, such as "input-2566"

how to handle these changes in selenium? to find elements..

P.S. there is about ~20 checkbox'es with a same element. Differs only number after input.

enter image description here


Solution

  • Please use below xpath, with method contains

    //label[contains(@for,'input') and contains(@class,'v-label theme--light')]
    

    update :

    You were missing (

    private static By checkboxSpecialist = By.xpath("(//label[contains(@for,'input') and contains(@class,'v-label theme--light')])[5]");