3 回答

TA贡献1831条经验 获得超9个赞
Work order number从dropdown“诱导”WebDriverWait和“跟随”xpath 选项中进行选择elementToBeClickable。
WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='el-select-dropdown__wrap el-scrollbar__wrap']/ul[@class='el-scrollbar__view el-select-dropdown__list']//li[./span[text()='Work order number']]")));
element.click()
或者
WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='el-select-dropdown__wrap el-scrollbar__wrap']/ul[@class='el-scrollbar__view el-select-dropdown__list']//li//span[text()='Work order number']")));
element.click()

TA贡献1775条经验 获得超11个赞
使用以下代码:
WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement dropdown = driver.findElement(By.xpath(".//ul[starts-with(@class,'el-scrollbar__view')]"));
List<WebElement> options = driver.findElements(By.xpath(".//li[starts-with(@class,'el-select-dropdown__item')]"));
public void selectOption(String option){
wait.until(ExpectedConditions.elementToBeClickable(dropdown));
dropdown.click();
wait.until(ExpectedConditions.visibilityOfAllElements(options));
for(WebElement element : options){
if(element.getText().equals(option))
element.click();
}
}

TA贡献1911条经验 获得超7个赞
使用下面的代码。
WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement dropdown = driver.findElement(By.xpath(".//ul[starts-with(@class,'el-scrollbar__view')]"));
List<WebElement> options = driver.findElements(By.xpath(".//li[starts-with(@class,'el-select-dropdown__item')]"));
@Test
public void testCase1() {
wait.until(ExpectedConditions.elementToBeClickable(dropdown));
dropdown.click();
wait.until(ExpectedConditions.visibilityOfAllElements(options));
for (WebElement element : options) {
element.click();
}
}
添加回答
举报