【发布时间】:2013-02-12 20:08:39
【问题描述】:
我想将wait.until(ExpectedConditions) 与两个元素一起使用。
我正在运行测试,我需要 WebDriver 等到 Element1 OR Element2 出现。然后我需要选择最先出现的人。我试过了:
WebDriverWait wait = new WebDriverWait(driver, 60);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//h2[@class='....']"))) || wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//h3[@class='... ']")));
// Then I would need:
String result = driver.findElement(By.xpath("...")).getText() || driver.findElement(By.xpath("...")).getText();
总而言之,我需要等到两个元素中的任何一个出现。然后选择出现的人(他们不能同时出现) 请帮忙。
【问题讨论】: