lundi 29 août 2016

error in alert handling in selenium

Does any know this answer? i have tried to solve it, but i could'nt find? could you help me to find? actually i am trying to automate a user browser login page. but there is a alert box available so i want to click ok in alert box . how it is possible? error in code

protected Alert getAlert(long wait) throws InterruptedException
    {
        WebDriverWait waitTime = new WebDriverWait(driver, wait);

        try
        {
            synchronized(waitTime)
            {
                Alert alert = driver.switchTo().alert();
                // if present consume the alert
                alert.accept();

                return alert;
            }

        }
        catch (NoAlertPresentException ex)
        {
            // Alert not present
            return null;
        }

    }

Aucun commentaire:

Enregistrer un commentaire