如何使用java处理selenium中动态生成的复选框
我想单击动态生成的复选框编号。 如何完成这项任务?请帮忙。 下面给出了复选框的Xpath序列如何使用java处理selenium中动态生成的复选框,java,selenium,selenium-webdriver,Java,Selenium,Selenium Webdriver,我想单击动态生成的复选框编号。 如何完成这项任务?请帮忙。 下面给出了复选框的Xpath序列 //*[@id="220077552"]/td[1]/app-checkbox/label //*[@id="220219925"]/td[1]/app-checkbox/label //*[@id="220077552"]/td[1]/app-checkbox/label 每次自动生成此id时。 应该使用什么来查找元素 我试过下面的代码 WaitUtils.waitForDataToLoad(
//*[@id="220077552"]/td[1]/app-checkbox/label
//*[@id="220219925"]/td[1]/app-checkbox/label
//*[@id="220077552"]/td[1]/app-checkbox/label
每次自动生成此id时。
应该使用什么来查找元素
我试过下面的代码
WaitUtils.waitForDataToLoad(getDriver());
List<WebElement> memberSelection = getDriver().findElements(By.cssSelector(".form-checkbox.notext"));
for(int count =1; count<=10; count++){
memberSelection.get(count).click();
}
您可以使用XPath函数,如start with、contains或end with 示例代码如下所示:
//*[starts-with(@id, '220')]
你试过什么吗?如果你确实发布了你的代码并解释了它的问题所在。您好,请附上html和代码示例。我们无法猜测到目前为止你做了什么@伙计,我已经发布了我尝试过的代码