Interrupt loading of site by condition in Selenium WebDriver

27 views
Skip to first unread message

plaidsh...@gmail.com

unread,
Oct 17, 2018, 3:56:52 AM10/17/18
to Selenium Users

There are multiple files which should be uploaded and waiting for output. It opens up an AJAX like window during processing. If processing takes too much time, Close button should be clicked on this window and file should be submitted again.

I try to use code below, but doesn't click Close button in 10 seconds.


public void clickOnSendButton() throws InterruptedException {
        WebDriverWait wait = new WebDriverWait(driver, 10);
        WebElement webElement;
        try {
            driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
            driver.findElement(sendButton).click();
            log.info("Processing in progress!");
            webElement = wait.until(ExpectedConditions.presenceOfElementLocated(By.className("button-download")));
        } catch (TimeoutException ex) {
            webElement = null;
        } finally {
            driver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS);
        }

        if (webElement == null) {
            driver.findElement(popUpClose).click();
            TimeUnit.SECONDS.sleep(1);
            driver.findElement(sendButton).click();
        }
}
Reply all
Reply to author
Forward
0 new messages