Код: Выделить всё
FluentWait fluentWait = new FluentWait(driver)
.withTimeout(Duration.ofSeconds(30))
.pollingEvery(Duration.ofMillis(200))
.ignoring(NoSuchElementException.class);
WebElement countryMx = initCountry.getMx();
fluentWait.until(d -> ExpectedConditions.visibilityOf(countryMx));
System.out.println("Element MX should be visible by now");
fluentWait.until(d -> ExpectedConditions.elementToBeClickable(countryMx));
System.out.println("Element MX should be clickable by now");
do {
executor.executeScript("arguments[0].scrollIntoView(true);", countryMx);
} while (!countryMx.isDisplayed());
countryMx.click();
Код: Выделить всё
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"#MX"}
< /code>
Когда я пробую альтернативный подход: < /p>
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(1));
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("MX")));
WebElement countryMx = initCountry.getMx();
do {
executor.executeScript("arguments[0].scrollIntoView(true);", countryMx);
} while (!countryMx.isDisplayed());
countryMx.click();
< /code>
Это работает ОК. Кроме того, я хочу подход и синтаксис, которые являются чистыми для использования с шаблоном PageObject. < /P>
Кроме того, если я попробую этот недиоматический (id = mx определяется в объекте страницы), он не работает в первом упомянутом способе (и не после 30 секунд, поэтому я бы сказал, что он просто не работает.fluentWait.until(d -> ExpectedConditions.presenceOfElementLocated(By.id("MX")));
Подробнее здесь: https://stackoverflow.com/questions/795 ... s-expected