Skip to content

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

@cyberspaceru

Description

@cyberspaceru

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;
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions