WileyLabs / teasy

Test easy with Teasy - UI automation testing framework
MIT License
31 stars 31 forks source link

Alert is unexpectedly closed by 'class PageLoaded implements ExpectedCondition<Boolean>' #177

Open cyberspaceru opened 6 years ago

cyberspaceru commented 6 years ago

Hi, I got some issue when I try to use AbstractPageElement.redirectTo with an opened alert on a page. It happens because of PageLoaded.class which try to get a state of the page by JavaScript. JavaScript will close the alert.

I suggest a solution, before using PageLoaded.class just check is an alert opened or not, for example, by this method:

   public static boolean alertIsPresent() {
        try {
            WebDriverWait wait = new WebDriverWait(getWebDriver(), 0);
            return wait.until(ExpectedConditions.alertIsPresent()) != null;
        } catch (TimeoutException e) {
            return false;
        }
    }
cyberspaceru commented 6 years ago
alertIsPresent() || "complete".equals(executeScript(String.class, "return document.readyState"))