Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cyberspaceru opened this issue Jun 6, 2018 · 1 comment

Comments

@cyberspaceru
Copy link

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
Copy link
Author

alertIsPresent() || "complete".equals(executeScript(String.class, "return document.readyState"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant