我有以下元素:硒等元素出現,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。代碼嘗試捕獲,但我沒有複製粘貼所有內容。我有興趣在它出現時正確檢測,並檢測它何時消失。 –
等待它出現或等待其消失的超時時間?如果你遇到超時,它最終會發現它嗎? –