java - 具有 Serenity 显式等待的 Selenium 在返回真实条件后继续执行
问题描述
具有 Serenity 显式等待的 Selenium 在返回真实条件后继续执行
所以,我想做的是等待显示繁忙的覆盖
元素仅在 DOM 中短暂出现大约 3 秒,然后从 DOM 中消失
System.out.println("Busy Overlay Displayed");
打印时满足条件这意味着
True
被退回但是,显式等待继续执行,
System.out.println("Size Appear = " + driver.findElements(By.xpath("//table[contains(@class,'tg-loading')]")).size());
之后继续执行并且打印大小 = 0True
为什么在满足条件后显式等待继续执行?public void waitForBusyOverlayDisplayed(WebDriver driver) { WebDriverWait wait = new WebDriverWait(driver, 5000); wait.until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver driver) { System.out.println("Size Appear = " + driver.findElements(By.xpath("//table[contains(@class,'tg-loading')]")).size()); if (driver.findElements(By.xpath("//table[contains(@class,'tg-loading')]")).size() == 1){ System.out.println("Busy Overlay Displayed"); return Boolean.TRUE; } return false; } }); }
解决方案
推荐阅读
- mysql - 在 MySQL 一张表中优化 SQL 查询
- html - Visual Basic 读取 HTML 以使用循环添加到列表
- ruby-on-rails - 具有唯一 To_do_list 的用户
- google-tag-manager - 将复杂数据层中的值放入 GTM 变量中
- javascript - Nativescript ios - 命令 xcodebuild 失败,退出代码为空
- javascript - 如何对多行字符串进行排序?
- laravel - Laravel Eloquent:使用 OrWhere 的多个 Wheres
- sql - 按日期透视 DateTime 字段
- ios - 在 Tableview Swift 中删除 Header View Section 的白色边框底部
- html - angular 5 动态反应形式