, . , , <span> -, foreach findElement , . getText. . , , - //span[text() == 'valueOfelementNameVariable'], WebDriverWait , .
, visibilityOfElementLocated, :
WebElement yourSpanElement = (new WebDriverWait(driver, 60))
.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text() == \"valueOfelementNameVariable\"]")));
, WebDriverWait DOM , ExpectedCondition true -. :
public V (com.google.common.base.Function isTrue)
:
the function returns neither null nor false,
the function throws an unignored exception,
the timeout expires,
the current thread is interrupted
visibilityOfElementLocated
public static ExpectedCondition<WebElement> visibilityOfElementLocated(
final By locator) {
return new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver driver) {
try {
return elementIfVisible(findElement(locator, driver));
} catch (StaleElementReferenceException e) {
return null;
}
}
@Override
public String toString() {
return "visibility of element located by " + locator;
}
};
}
(, null, ), , -, .
?
Object Object. , PageFactory, , ( ), , WebElements , , , .