【发布时间】:2021-07-29 12:11:43
【问题描述】:
我为 React Web 应用程序做了自动化。
寻求帮助以实现以下场景,
我正在单击页面上的按钮。单击按钮后,页面会加载图像。
加载图像大约需要 5 秒。
此外,图像加载到新创建的元素,
(在点击之前的页面中,没有用于加载图像的div,但在我点击按钮后,它会出现在页面上,并且在加载的div 图像内部)。
在我的方法中,我试图验证按钮单击后是否加载了图像。
但它总是返回NoSuchElementException。
注意:如果我使用上面的 xpath 手动搜索元素,该元素会突出显示
以下是我尝试过的方法
1.
public static boolean waitElementPresent(SelenideElement element) {
try {
element.should(Condition.appear, Duration.ofSeconds(TIME_OUT));
return true;
} catch (Exception e) {
return false;
}
}
2.
public static boolean waitElementPresent(SelenideElement element) {
try {
element.should(Condition.visible, Duration.ofSeconds(TIME_OUT));
return true;
} catch (Exception e) {
return false;
}
}
【问题讨论】:
-
有可用的网址吗?
-
可能原因:1. 缺少切换到帧 2. 等待时间不足 3. 定位器错误 4. 上述任意组合
-
@theNishant 不,这是在本地主机中,
-
@pburgr 我检查了您提到的上述情况,但仍然相同
标签: java selenium automated-tests selenide