1

找不到元素,因为每次刷新页面,元素id都会自动改变

在此处输入图像描述

刷新后“input-19”更改为任何其他,例如“input-2566”

如何处理硒的这些变化?寻找元素..

PS 大约有 20 个复选框具有相同的元素。输入后仅数字不同。

在此处输入图像描述

4

2 回答 2

1

请使用下面的xpath,方法contains

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

更新 :

你失踪了(

private static By checkboxSpecialist = By.xpath("(//label[contains(@for,'input') and contains(@class,'v-label theme--light')])[5]");
于 2021-10-28T11:17:19.243 回答
0

你可以尝试这样的事情:

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
    })

使用 xpath,而不是元素 id

于 2021-10-28T11:17:04.977 回答