Actually I am working on one script in my application there I need to wait till its complete the execution, once complete the execute it will change the status. But I don't know when the execution completes (Dynamic time).
This is web-based application and I am not sure which wait or feature or method I need to use to wait until it satisfy the condition. Below is the sample code I tried (Can not post exact code).
Please suggest me how to proceed with or any suggestion on this.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.FluentWait;
import com.google.common.base.Function;
public class TestingClass {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.gecko.driver", "D:\\SeleniumClass\\src\\libs\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://toolsqa.com/automation-practice-switch-windows/");
FluentWait<WebDriver> wait = new FluentWait<WebDriver>(driver);
wait.pollingEvery(Duration.ofHours(5));
wait.withTimeout(Duration.ofMinutes(1));
Function<WebDriver, Boolean> function = new Function<WebDriver, Boolean>()
{
public Boolean apply(WebDriver arg0) {
WebElement element = arg0.findElement(By.id("tabButton"));
String type = element.getAttribute("type");
System.out.println("The type is " + type);
if(type.equals("button"))
{
return true;
}
return false;
}
};
wait.until(function);
}
}