I'm connecting to a website multiple times every few seconds and sometimes the website just enters a HUGE loading phase where it takes like 5 minutes to stop loading. When it finally stops, it throws an expected ElementNotFoundException which i then catch and restart the process from the last point. However, i want to be able to detect this loading phase and handle it as soon as possible instead of waiting 5 minutes for it to end. I tried using a FluentWait implementation and a WebDriverWait one but none works so far. Here are the two implementations i tried :
FluentWait :
private static WebElement fluentWait(final By locator, WebDriver driver) {
    Wait<WebDriver> wait = new FluentWait<>(driver)
            .withTimeout(10, TimeUnit.SECONDS)
            .pollingEvery(2, TimeUnit.SECONDS);
            //.ignoring(NoSuchElementException.class);
    return wait.until((Function<WebDriver, WebElement>) driver1 -> {
        assert driver1 != null;
        return driver1.findElement(locator);
    });
    }
WebDriverWait:
new WebDriverWait(driver,5).until(ExpectedConditions.presenceOfElementLocated(new By.ByCssSelector(someSelector)));
P.S: I'm using Selenium Webdriver and specifically ChromeDriver(). Here's an image of how the website looks when it enters that huge loading phase ->

 
     
    