我有以下元素:硒等元素出现,dissapear
<div class="ui-helper-hidden" id="shell.indicator.busy">
<label>Processing...</label>
<br />
<img src="/RightCrowd/Images/loading.gif" alt="" />
</div>
,它似乎是这样的:
我想等待它出现,然后消失并继续访问元素。这出现在Web应用程序的大多数页面上。我们尝试了一些东西,但有时可以看到硒,有时不是,虽然我可以用我的眼睛看到它。
我相信这个处理图像出现在当前页面的顶部,并且使用当前处理程序可能没用。不确定。
我们试过这样的事情:
WebElement element = (new WebDriverWait(webDriver, 10))
.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//img[contains(@src,'/Images/loading.gif')]")));
boolean processingEnd = (new WebDriverWait(webDriver, timeoutWaitForProgressbar))
.until(ExpectedConditions.invisibilityOfElementLocated(By.id("shell.indicator.busy")));
所以我们都试过XPath和ID ...请让我知道什么是处理这种情况的最好办法。
当您使用xpath和ID尝试它时发生了什么?它是否抛出异常?哪个例外? –
这是一个TimeoutException。代码尝试捕获,但我没有复制粘贴所有内容。我有兴趣在它出现时正确检测,并检测它何时消失。 –
等待它出现或等待其消失的超时时间?如果你遇到超时,它最终会发现它吗? –