I can't find element, because every time I refresh page, the element id is changed automatically
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.
CodePudding user response:
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]");
CodePudding user response:
u can try something like that:
const button = await driver.wait(
until.elementLocated(By.xpath('YOUR XPATH ELEMENT')), 15000).then(button => {
return driver.wait(
until.elementIsVisible(button),
15000)}
})
button3.sendKeys('your text ').then(async function() {
console.log(button.sendKeys,'input - done');
return true
})
use xpath, not element id