我有3个测试功能,一个创建用户,然后第二个从列表中选择创建的用户,第三个删除它。 创建和保存用户功能可以很好地工作,但是在删除功能中,尽管添加了各种等待,但当进度条仍与之重叠并失败时,它会搜索删除按钮。 为了进一步补充,我尝试了其他问题中提供的解决方案,但没有任何效果。 我的情况是我要等到进度条消失后再单击删除按钮,然后单击它,按钮才不会被单击。
我将附加相同的代码:
public void deleteUser(String username)
{
wait= new WebDriverWait(driver,20);
wait.until(ExpectedConditions.invisibilityOfElementLocated(progressbar));
System.out.println(driver.findElement(deleteButton).getText());
try
{
wait.until(ExpectedConditions.elementToBeClickable(deleteButton));
driver.findElement(deleteButton).click();
System.out.println("Button clicked");
wait.until(ExpectedConditions.alertIsPresent());
}
catch (Exception e)
{
System.out.println(e);
}
我得到的错误:
org.openqa.selenium.WebDriverException: unknown error: Element <button type="button" ng-click="delete()" ng-disabled="readonly || isNew" class="btn btn-danger btn-sm">...</button> is not clickable at point (786, 185). Other element would receive the click: <div ng-show="inProcess" class="progress">...</div>
用于删除和进度栏的HTML代码:
<button type="button" ng-click="delete()" ng-disabled="readonly || isNew" class="btn btn-danger btn-sm">
<span class="glyphicon glyphicon-trash"></span>
Delete
</button>
<div ng-show="inProcess" class="progress ng-hide">
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
<span>Processing ...</span>
</div>