Example usage for org.openqa.selenium.support.ui WebDriverWait WebDriverWait

List of usage examples for org.openqa.selenium.support.ui WebDriverWait WebDriverWait

Introduction

In this page you can find the example usage for org.openqa.selenium.support.ui WebDriverWait WebDriverWait.

Prototype

public WebDriverWait(WebDriver driver, Duration timeout) 

Source Link

Document

Wait will ignore instances of NotFoundException that are encountered (thrown) by default in the 'until' condition, and immediately propagate all others.

Usage

From source file:applango.common.dashboardTests.java

@Test
//Passing/*from  www.  j  a va 2  s.  com*/
public void testLicenseCost() throws ParserConfigurationException, SAXException, IOException {
    String licenseType = "FDC_SUB";
    Applango applango = getApplangoConfigurationXML();
    driver1 = getRemoteWebDriver(DesiredCapabilities.chrome());
    //        FirefoxDriver driver = getFirefoxDriver();
    WebDriverWait wait = new WebDriverWait(driver1, timeOutInSeconds());
    final String connection = dbTables.licenseApp.getValue().toString();
    DBCollection coll = db.getCollection(connection);
    try {
        genericApplangoWebsiteActions.openDashboardAndLogin(applango, driver1, wait);
        genericApplangoWebsiteActions.checkLicenseCostInApplicationPageBeforeUpdate(licenseType, driver1, wait,
                coll);
        checkLicenseCostInAccountPageBeforeUpdate(driver1, wait);
        genericApplangoWebsiteActions.updateLicenseCostInDBAndReloadApplicationData(licenseType, driver1, wait,
                coll);
        checkLicenseCostInApplicationPageAfterUpdate(driver1, wait);
        checkLicenseCostInAccountPageAfterUpdate(driver1, wait);

    } finally {
        mongoDB.updateLicensePrice(coll, licenseType, 30);
        driver1.close();
    }

}

From source file:applango.common.dashboardTests.java

@Test
public void testGroupByLicenseType() throws ParserConfigurationException, SAXException, IOException {
    Applango applango = getApplangoConfigurationXML();
    driver1 = getRemoteWebDriver(DesiredCapabilities.chrome());
    WebDriverWait wait = new WebDriverWait(driver1, timeOutInSeconds());
    final String connection = dbTables.groupInfo.getValue().toString();
    DBCollection coll = db.getCollection(connection);
    String licenseType = salesforceLicenses.FORCE.getValue().toString();
    try {/*from  www.  j a v  a 2s . c o m*/
        BasicDBObject documentBuilder = new BasicDBObject("appName", "salesforce")
                .append("customerId", "automationCustomer").append("externalId", "00520000003ClOvAAK");
        String lastName = "Hilsta";
        logger.info("Check that user is in [groupInfo] table with group 'Chatter Free'");
        if (coll.find(documentBuilder).next().get("groups").toString().toLowerCase()
                .contains(licenseType.toLowerCase())) {
            genericApplangoWebsiteActions.openDashboardAndLogin(applango, driver1, wait);
            driver1.manage().window().maximize();

            //                driver.findElement(By.id("//*[@id=\"licenz\"]/span[2]")).click();

            logger.info("Check that user exist in usertable when filtering by " + licenseType);
            genericApplangoWebsiteActions.filterLicenseType(driver1, wait, salesforceLicenses.FORCE);
            genericApplangoWebsiteActions.enterValueInSearchLastName(driver1, lastName);
            assertTrue(driver1.findElement(By.id(applangoObject.USERTABLE.getValue().toString())).getText()
                    .contains(lastName));
            //check Groups field

            logger.info("Check that user not exist in usertable when filtering by "
                    + salesforceLicenses.SYSTEM_ADMINISTRATOR.getValue());
            genericApplangoWebsiteActions.filterLicenseType(driver1, wait,
                    salesforceLicenses.SYSTEM_ADMINISTRATOR);
            genericApplangoWebsiteActions.enterValueInSearchLastName(driver1, lastName);
            assertFalse(driver1.findElement(By.id(applangoObject.USERTABLE.getValue().toString())).getText()
                    .contains(lastName));
        }
    } finally {
        driver1.close();
    }
}

From source file:applango.common.dashboardTests.java

@Test
@Ignore// w  ww  . ja v a  2  s .co  m
public void testDashboardFilterDate() throws ParserConfigurationException, SAXException, IOException {
    Applango applango = getApplangoConfigurationXML();
    FirefoxDriver driver1 = getFirefoxDriver();
    WebDriverWait wait1 = new WebDriverWait(driver1, 15);
    wait1.withTimeout(50, TimeUnit.SECONDS);
    try {
        genericApplangoWebsiteActions.openDashboardAndLogin(applango, driver1, wait1);
        //            genericApplangoWebsiteActions.filterLicenseType(driver1, wait1, SALESFORCE);
        filterByDate(driver1, wait1, "2013", months.SEPTEMBER, "", months.JANUARY); //Blank toYear in order to keep is till 2014

        genericApplangoWebsiteActions.waitForUsersTableToLoad(wait1);

    } catch (Exception ex) {
        logger.error(ex.getMessage());
        fail("Failed due to : " + ex.getMessage());
    } finally {
        driver1.close();
    }
}

From source file:applango.common.dashboardTests.java

@Test
public void testChangePassword() throws ParserConfigurationException, SAXException, IOException {
    logger.info("********************************************* Running  "
            + Thread.currentThread().getStackTrace()[1].getMethodName()
            + "*********************************************");
    driver1 = getRemoteWebDriver(DesiredCapabilities.chrome());
    WebDriverWait wait = new WebDriverWait(driver1, timeOutInSeconds());
    Applango applango = getApplangoConfigurationXML();
    String currentPassword = applango.getPassword();
    String tooShortNewPassword = "Omer19";
    String onlyLettersPassword = "OmerOvadia";
    String onlyNumbersPassword = "123456789";
    String validNewPassword = applango.getPassword();
    String emptyPassword = "";

    try {//w ww.  j  a  va 2 s.c o  m
        genericApplangoWebsiteActions.openDashboardAndLogin(applango, driver1, wait);
        genericApplangoWebsiteActions.openUserAccount(driver1, wait);
        genericApplangoWebsiteActions.clickOnChangePassword(driver1, wait);

        logger.info(" Entering password shorter than 8 digits");
        genericApplangoWebsiteActions.fillChangePasswordAndSubmit(driver1, currentPassword, tooShortNewPassword,
                tooShortNewPassword);
        genericApplangoWebsiteActions.checkChangePasswordMessage(driver1,
                applangoMessages.CHANGE_PASSWORD_INVALID_TOO_SHORT);

        logger.info(" Entering not matching password");
        genericApplangoWebsiteActions.fillChangePasswordAndSubmit(driver1, currentPassword, validNewPassword,
                validNewPassword + "1");
        genericApplangoWebsiteActions.checkChangePasswordMessage(driver1,
                applangoMessages.CHANGE_PASSWORD_NOT_MATCH);

        logger.info("Entering password that has letters only");
        genericApplangoWebsiteActions.fillChangePasswordAndSubmit(driver1, currentPassword, onlyLettersPassword,
                onlyLettersPassword);
        genericApplangoWebsiteActions.checkChangePasswordMessage(driver1,
                applangoMessages.CHANGE_PASSWORD_INVALID_LETTERS_AND_NUMBERS);

        logger.info("Entering password that has numbers only");
        genericApplangoWebsiteActions.fillChangePasswordAndSubmit(driver1, currentPassword, onlyNumbersPassword,
                onlyNumbersPassword);
        genericApplangoWebsiteActions.checkChangePasswordMessage(driver1,
                applangoMessages.CHANGE_PASSWORD_INVALID_LETTERS_AND_NUMBERS);

        logger.info("Entering empty new password");
        genericApplangoWebsiteActions.fillChangePasswordAndSubmit(driver1, currentPassword, emptyPassword,
                emptyPassword);
        genericApplangoWebsiteActions.checkChangePasswordMessage(driver1,
                applangoMessages.CHANGE_PASSWORD_EMPTY);

        logger.info("Entering empty current password");
        genericApplangoWebsiteActions.fillChangePasswordAndSubmit(driver1, emptyPassword, validNewPassword,
                validNewPassword);
        genericApplangoWebsiteActions.checkChangePasswordMessage(driver1,
                applangoMessages.CHANGE_PASSWORD_EMPTY_CURRENT_PASSWORD);

        logger.info("Entering valid new password");
        genericApplangoWebsiteActions.fillChangePasswordAndSubmit(driver1, currentPassword, validNewPassword,
                validNewPassword);
        //            genericApplangoWebsiteActions.checkChangePasswordMessage(driver1, applangoMessages.CHANGE_PASSWORD_SUCCESSFULLY);
    } catch (Exception ex) {
        logger.error(ex.getMessage());
        fail("Failed due to : " + ex.getMessage());
    } finally {
        driver1.close();
    }
}

From source file:applango.common.dashboardTests.java

@Test
@Ignore/* w w  w .  j  av  a 2s  . c  o m*/
public void testResetPasswordEmailRecieved() throws ParserConfigurationException, SAXException, IOException {
    logger.info("********************************************* Running  "
            + Thread.currentThread().getStackTrace()[1].getMethodName()
            + "*********************************************");
    Gmail gmail = genericGmailWebsiteActions.getGmailConfigurationXML();
    FirefoxDriver driver = getFirefoxDriver();
    FirefoxDriver driver1 = getFirefoxDriver();
    WebDriverWait wait = new WebDriverWait(driver, 15);
    WebDriverWait wait1 = new WebDriverWait(driver1, 15);
    Applango applango = getApplangoConfigurationXML();
    String validUsername = applango.getUsername();
    long sleepTime = 13000;
    final String connection = dbTables.emailToken.getValue().toString();

    try {
        //Remove emailTokens
        logger.info("Connect to db table " + connection);
        DBCollection coll = db.getCollection(connection);
        mongoDB.removeRecordsFromDB(applango, coll);

        //Gmail Get Inbox
        logger.info("Open Gamil and get current inbox amount");
        loginToGmail(gmail, driver, wait);
        String amountOfMailBeforeResetPassword = genericGmailWebsiteActions.getInboxLabel(driver);
        //Applango Recover Password
        logger.info("Recover Password via dashboard login page ");
        genericApplangoWebsiteActions.openDashboard(applango, driver1, wait1);
        genericApplangoWebsiteActions.clickOnForgotPassword(driver1, wait1);
        genericApplangoWebsiteActions.enterUsernameInForgotPasswordTextfield(driver1, validUsername);
        genericApplangoWebsiteActions.clickOnRecoverPassword(driver1, wait1);

        logger.info("Get new token from DB");
        String token = mongoDB.getSpecialToken(applango, coll);
        token = mongoDB.encodeToken(token);
        logger.info("Token is " + token);

        //Gmail click on link and set new password
        logger.info(
                "Wait few seconds and click on Inbox label in order to refresh inbox and compare no. of mails in order to make sure mail received");
        genericGmailWebsiteActions.checkNewMailRecieved(driver, sleepTime, amountOfMailBeforeResetPassword);

    } catch (Exception ex) {
        logger.error(ex.getMessage());

        fail("Failed due to : " + ex.getMessage());
    } finally {
        driver.close();
        driver1.close();
    }
}

From source file:applango.common.dashboardTests.java

@Test
@Ignore/* w ww.  j  av  a 2  s .c o m*/
public void testResettingPasswordFromEmail() throws ParserConfigurationException, SAXException, IOException {
    logger.info("********************************************* Running  "
            + Thread.currentThread().getStackTrace()[1].getMethodName()
            + "*********************************************");
    Gmail gmail = genericGmailWebsiteActions.getGmailConfigurationXML();
    FirefoxDriver driver1 = getFirefoxDriver();
    WebDriverWait wait1 = new WebDriverWait(driver1, 15);
    Applango applango = getApplangoConfigurationXML();
    String validPassword = applango.getPassword();
    String invalidPasswordNoDigits = "NoDigitsPwd";
    String invalidPasswordNoChars = "123456789";
    String invalidPasswordTooShort = "12345a";
    long sleepTime = 13000;
    //        Database dbProperties = getDatabaseConfigurationXML();
    final String connection = dbTables.emailToken.getValue().toString();
    try {
        logger.info("Get new token from DB");
        //            DB db = connectToDB(dbProperties);
        DBCollection coll = db.getCollection(connection);
        String token = mongoDB.getSpecialToken(applango, coll);
        token = mongoDB.encodeToken(token);
        logger.info("Token is " + token);

        logger.info("Try again to open mail and locate link..");
        loginToGmail(gmail, driver1, wait1);

        logger.info("Check that the mail is from applango with correct subject)");
        genericGmailWebsiteActions.checkMailSubjectIsResetPassword(driver1);
        genericGmailWebsiteActions.checkMailSenderIsApplango(driver1);
        genericGmailWebsiteActions.clickOnFirstMail(driver1, wait1);

        genericGmailWebsiteActions.waitForMailToLoad(wait1);
        genericGmailWebsiteActions.checkResetPasswordToken(driver1, token);
        genericGmailWebsiteActions.clickOnChangePasswordLink(driver1);

        logger.info("Set new Password in Change Password screen");
        String gmailWinID = controlAndSwitchWindow(driver1);
        genericApplangoWebsiteActions.checkEnterNewPasswordScreenLoaded(driver1, wait1);

        logger.info("Negative test - set password with invalid passwords");
        genericApplangoWebsiteActions.fillChangePasswordAndSubmit(driver1, null, validPassword,
                validPassword + "A", true);
        genericApplangoWebsiteActions.checkChangePasswordMessage(driver1,
                applangoMessages.CHANGE_PASSWORD_NOT_MATCH);

        genericApplangoWebsiteActions.fillChangePasswordAndSubmit(driver1, null, invalidPasswordNoChars,
                invalidPasswordNoChars, true);
        genericApplangoWebsiteActions.checkChangePasswordMessage(driver1,
                applangoMessages.CHANGE_PASSWORD_INVALID_LETTERS_AND_NUMBERS);

        genericApplangoWebsiteActions.fillChangePasswordAndSubmit(driver1, null, invalidPasswordNoDigits,
                invalidPasswordNoDigits, true);
        genericApplangoWebsiteActions.checkChangePasswordMessage(driver1,
                applangoMessages.CHANGE_PASSWORD_INVALID_LETTERS_AND_NUMBERS);

        genericApplangoWebsiteActions.fillChangePasswordAndSubmit(driver1, null, invalidPasswordTooShort,
                invalidPasswordTooShort, true);
        genericApplangoWebsiteActions.checkChangePasswordMessage(driver1,
                applangoMessages.CHANGE_PASSWORD_INVALID_TOO_SHORT);

        logger.info("Set valid Password in Change Password screen");
        genericApplangoWebsiteActions.fillChangePasswordAndSubmit(driver1, null, validPassword, validPassword,
                true);

        logger.info("Verify pop up message and click on 'Yes'");
        controlAndSwitchWindow(driver1);
        genericApplangoWebsiteActions.verifyPasswordSuccessfulyChangedMessageAppear(driver1);

        //Applango login with new password
        logger.info("Login with new password");
        genericApplangoWebsiteActions.openDashboardAndLogin(applango, driver1, wait1);
    } catch (Exception ex) {
        logger.error(ex.getMessage());
        fail("Failed due to : " + ex.getMessage());
    } finally {
        driver1.close();
    }
}

From source file:applango.common.dashboardTests.java

@Test
public void testAlertTrigger() throws Throwable {
    //        Applango applango = getApplangoConfigurationXML();
    driver1 = getRemoteWebDriver(DesiredCapabilities.chrome());
    WebDriverWait wait1 = new WebDriverWait(driver1, timeOutInSeconds());

    try {//from ww  w . ja v  a2s.  co m
        genericApplangoWebsiteActions.openDashboardAndLogin(applango, driver1, wait1);
        genericApplangoWebsiteActions.openUserAccount(driver1, wait1);
        String thresholdLow = "0";
        String thresholdHigh = "2000";

        genericApplangoWebsiteActions.setBoxNoLoginAlertThreshold(driver1, thresholdLow);
        clickSaveBoxNoLogin(driver1, wait1);
        genericApplangoWebsiteActions.clickOnUpdateAlert(driver1, wait1);
        driver1.navigate().refresh();
        genericApplangoWebsiteActions.waitUntilWaitForServerDissappears(wait1);
        assertTrue(checkAlertTrigger(driver1));

        genericApplangoWebsiteActions.setBoxNoLoginAlertThreshold(driver1, thresholdHigh);
        clickSaveBoxNoLogin(driver1, wait1);
        genericApplangoWebsiteActions.clickOnUpdateAlert(driver1, wait1);
        driver1.navigate().refresh();
        genericApplangoWebsiteActions.waitUntilWaitForServerDissappears(wait1);
        assertFalse(checkAlertTrigger(driver1));
    } finally {
        driver1.close();
    }
}

From source file:applango.common.dashboardTests.java

@Test
public void testReportPage() throws IOException {
    driver1 = getRemoteWebDriver(DesiredCapabilities.chrome());
    WebDriverWait wait1 = new WebDriverWait(driver1, timeOutInSeconds());

    try {//from   www  .  j  a va 2  s. co m
        genericApplangoWebsiteActions.openDashboardAndLogin(applango, driver1, wait1);
        genericApplangoWebsiteActions.openReportPage(driver1, wait1);

        logger.info("Run ove all reports");
        for (applangoReports report : applangoReports.values()) {
            selectReport(driver1, report);
            for (applications application : applications.values()) {
                selectReportApplication(driver1, application);
                logger.info(
                        "Run Report : " + report.getValue() + " for application : " + application.getValue());
                clickOnReportSearch(driver1, wait1);

            }

        }

        genericApplangoWebsiteActions.clickOnReportDownload(driver1, wait1);
        genericApplangoWebsiteActions.clickOnReportExportCSV(driver1, wait1);

    } finally {
        //            driver0.quit();
    }
}

From source file:applango.common.dashboardTests.java

@Test

public void testPeoplePage() throws Throwable {
    driver1 = getRemoteWebDriver(DesiredCapabilities.chrome());
    WebDriverWait wait1 = new WebDriverWait(driver1, timeOutInSeconds());
    String firstName = "omer";
    String lastName = "ovadia";
    String email = null;/* ww  w.j a v a  2  s  .com*/
    try {
        genericApplangoWebsiteActions.openDashboardAndLogin(applango, driver1, wait1);
        genericApplangoWebsiteActions.openPeoplePage(driver1, wait1);
        genericApplangoWebsiteActions.searchPeople(driver1, wait1, firstName, lastName, email, thisMonth,
                thisYear, thisMonth, thisYear);
        genericApplangoWebsiteActions.clickOnUserInPeopleTable(driver1, wait1);
        genericApplangoWebsiteActions.clickOnAppInPeopleTable(driver1, wait1);
    } finally {
        driver1.quit();
    }

}

From source file:applicationdriverlayer.pageobjects.squash.booking.CourtAndTimeSlotChooserPage.java

License:Apache License

@Override
protected void waitForLoadToComplete() {
    new WebDriverWait(driver, explicitWaitTimeoutSeconds)
            .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.className("booking-table")));
    new WebDriverWait(driver, explicitWaitTimeoutSeconds).until(ExpectedConditions.visibilityOf(dateDropdown));
}