I posed with a difficult task. I am new to selenium and still working on functionality for expecting elements and the like.
I need to manipulate some data on a website and then move on to another. Problem: the manipulation calls a script, which makes a small label "Save ..." while the data being processed is processed in the background. I need to wait until I go to the next website.
So here it is: How am I waiting for the DISAPPEAR element? The thing is this: it is always present in the DOM, but is visible only to some script (I assume, see the image below).

This is what I tried, but it just doesn’t work - there is no waiting, selenium simply proceeds to the next step (and gets stuck with a warning asking me if I want to leave or stay on the page because of "saving ...").
private By savingLableLocator = By.id("lblOrderHeaderSaving");
public boolean waitForSavingDone(By webelementLocator, Integer seconds){
WebDriverWait wait = new WebDriverWait(driver, seconds);
Boolean element = wait.until(ExpectedConditions.invisibilityOfElementLocated(webelementLocator));
return element;
}
UPDATE / DECISION:
I came up with the following solution: I built my own method. It basically checks for CssValue changes in the loop.
loops check a certain amount of time for the CSSVALUE “display” to transition from the “block” to another state.
public void waitForSavingOrderHeaderDone(Integer _seconds){
WebElement savingLbl = driver.findElement(By.id("lblOrderHeaderSaving"));
for (int second = 0;; second++) {
if (second >= _seconds)
System.out.println("Waiting for changes to be saved...");
try {
if (!("block".equals(savingLbl.getCssValue("display"))))
break;
} catch (Exception e) {
}
}
source
share