Is there a way to have selenium wait for 3 minutes before refreshing the page until a specific element (in this case, the Download button) is found? I've attempted the code below, but it doesn't seem to be effective.
Note: I am trying to upload a zip file which sometimes takes a few seconds and other times up to 3 minutes. The code works fine when the file uploads quickly, but fails when it takes longer.
Any suggestions on how to improve this?
boolean displayed = false;
do {
try {
displayed = driver1.findElement(By.xpath("//*[@id=\"app\"]/main/div[1]/div/div/div/div[2]/table/tbody/tr[1]/td[4]/a")).isDisplayed();
} catch (NoSuchElementException e) {
System.out.println(e);
driver1.navigate().refresh();
}
} while (!displayed);
driver1.findElement(By.xpath("//*[@id=\"app\"]/main/div[1]/div/div/div/div[2]/table/tbody/tr[1]/td[4]/a")).click();