Example usage for org.openqa.selenium.support.ui ExpectedConditions titleContains

List of usage examples for org.openqa.selenium.support.ui ExpectedConditions titleContains

Introduction

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

Prototype

public static ExpectedCondition<Boolean> titleContains(final String title) 

Source Link

Document

An expectation for checking that the title contains a case-sensitive substring

Usage

From source file:GeneralCookieDriver.java

License:Open Source License

public Integer conductTest(Browser browser, boolean privateBrowsing, int[] cookies, int numTrialsPerRun) {
    WebDriver driver = getWebDriver(browser, privateBrowsing);

    if (driver == null) {
        System.err.println("WebDriver could not be found for " + browser + " in "
                + (privateBrowsing ? "private" : "normal") + " mode.");
        return 0;
    }//from   www  .  ja v  a 2  s. com

    if (browser.equals(Browser.SAFARI) && privateBrowsing) {
        System.err.println("Pausing for 10 seconds...");
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.err.println("Resuming from pause...");
    }

    for (int c = 0; c < cookies.length; c++) {

        for (int i = 0; i < numTrialsPerRun; i++) {

            driver.get(new String(cookieGeneratorLocation + "?numCookies=" + cookies[c] + "&browser="
                    + browser.toString() + "&mode=" + (privateBrowsing ? "private" : "normal")));

            try {
                new WebDriverWait(driver, 120).until(ExpectedConditions.titleContains("[ResultProvided]"));

            } catch (org.openqa.selenium.UnhandledAlertException e) {
                System.err.println("UnhandledAlertException");
                continue;
            } catch (Exception e) {
                e.printStackTrace();
                continue;
            }

            Integer result = new Integer(driver.getTitle().split(" ")[0]);

            System.out.println(
                    browser.toString() + (privateBrowsing ? ",P," : ",N,") + cookies[c] + "," + result);
        }
    }

    //Close the browser
    driver.quit();

    return 0;
}

From source file:com.asiainfo.tfsPlatform.modules.test.selenium.Selenium2.java

License:Apache License

/**
 * ?title,timeout.
 */
public void waitForTitleContains(String title) {
    waitForCondition(ExpectedConditions.titleContains(title), DEFAULT_WAIT_TIME);
}

From source file:com.asiainfo.tfsPlatform.modules.test.selenium.Selenium2.java

License:Apache License

/**
 * ?title, timeout??.//from  w w  w . ja  va  2  s.c  o m
 */
public void waitForTitleContains(String title, int timeout) {
    waitForCondition(ExpectedConditions.titleContains(title), timeout);
}

From source file:com.dhenton9000.selenium.generic.WaitMethods.java

public void waitForExpectedPage(int timeInSeconds, String pageTitle) {

    WebDriverWait wait = new WebDriverWait(driver, timeInSeconds);
    wait.until(ExpectedConditions.titleContains(pageTitle));

}

From source file:com.ggasoftware.uitest.utils.WebDriverWrapper.java

License:Open Source License

/**
 * Wait until windows title contains text.
 *
 * @param timeoutSec     to wait until windows title contains text.
 * @param title          - Expected window title contains text.
 * @param checkCondition - log assert for expected conditions.
 *//*  ww  w  . ja  v  a  2 s .c  o  m*/
public static void waitForTitleContains(String title, int timeoutSec, boolean checkCondition) {
    ReporterNGExt.logAction(getDriver(), "", String.format("waitForTitleContains: %s", title));
    long start = System.currentTimeMillis() / 1000;
    WebDriverWait wait = (WebDriverWait) new WebDriverWait(getDriver(), timeoutSec)
            .ignoring(StaleElementReferenceException.class);
    try {
        wait.until(ExpectedConditions.titleContains(title));
    } catch (TimeoutException ignored) {
        ReporterNGExt.logTechnical(String.format("waitForTitleContains: [ %s ] during: [ %d ] sec ", title,
                System.currentTimeMillis() / 1000 - start));
    }
    if (checkCondition) {
        ReporterNGExt.logAssertContains(ReporterNGExt.BUSINESS_LEVEL, getDriver().getTitle(), title,
                "waitForTitleContains", TestBaseWebDriver.takePassedScreenshot);
    }
}

From source file:com.ggasoftware.uitest.utils.WebDriverWrapper.java

License:Open Source License

/**
 * Wait until windows title not contains text.
 *
 * @param timeoutSec     to wait until windows title not contains text.
 * @param title          - Expected window title not contains text.
 * @param checkCondition log assert for expected conditions.
 *///from w ww.  j av  a 2s. c o  m
public static void waitForTitleNotContains(String title, int timeoutSec, boolean checkCondition) {
    ReporterNGExt.logAction(getDriver(), "", String.format("waitForTitleNotContains: %s", title));
    long start = System.currentTimeMillis() / 1000;
    WebDriverWait wait = (WebDriverWait) new WebDriverWait(getDriver(), timeoutSec)
            .ignoring(StaleElementReferenceException.class);
    try {
        wait.until(ExpectedConditions.not(ExpectedConditions.titleContains(title)));
    } catch (TimeoutException ignored) {
        ReporterNGExt.logTechnical(String.format("waitForTitleNotContains: [ %s ] during: [ %d ] sec ", title,
                System.currentTimeMillis() / 1000 - start));
    }
    if (checkCondition) {
        ReporterNGExt.logAssertNotContains(ReporterNGExt.BUSINESS_LEVEL, getDriver().getTitle(), title,
                "waitForTitleNotContains", TestBaseWebDriver.takePassedScreenshot);
    }
}

From source file:com.ionidea.RegressionNGA.Tests.FooterTest.java

License:Open Source License

/**
 * the method verifies that the opened page is respective to the used sub menu option
 * @param url //w ww  .  j  a  v a2 s  . com
 * @param title
 * @param mainMenu 
 */

public void verifyOpenedPage(String url, String title) throws InterruptedException {

    //create excplicite wait

    m_wait.until(ExpectedConditions.titleContains(title));
    //verify URL and title of the opened page
    Assert.assertTrue(driver.getCurrentUrl().contains(url));
    Assert.assertTrue(driver.getTitle().contains(title));

}

From source file:com.ionidea.RegressionNGA.Tests.MainPageHeaderTest.java

/**
 * the method verifies that the opened page is respective to the used sub menu option
 * @param relativeUrl /*w w  w .j  a  v  a2  s.c o  m*/
 * @param mainMenu 
 */

public void verifyOpenedPage(String relativeUrl, String title, Integer mainMenuIndex) {

    //verify that the title contains correct value           
    if (mainMenuIndex == 8) {
        m_wait.until(ExpectedConditions.urlContains("https://shop.nga.gov" + relativeUrl));
        Assert.assertTrue(driver.getCurrentUrl().contains("https://shop.nga.gov" + relativeUrl));
        System.out.println(relativeUrl);
    } else {
        m_wait.until(ExpectedConditions.urlContains(m_baseUrl + relativeUrl));
        Assert.assertTrue(driver.getCurrentUrl().contains(m_baseUrl + relativeUrl));
        System.out.println(relativeUrl);
    }
    //verify that the URL of opened page is correct 
    m_wait.until(ExpectedConditions.titleContains(title));
    Assert.assertTrue(driver.getTitle().contains(title));
    System.out.println("the page is loaded");
}

From source file:com.pentaho.ctools.cda.CDACacheManager.java

License:Apache License

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name://  ww  w . j  a  va2s.c  o  m
 *    Page Content
 * Description:
 *    The test case pretends to validate the page contents in 'CachedQueries.
 * Steps:
 *    1. Check for text 'Queries in cache'
 *    2. Check for button 'Clear Cache'
 */
@Test
public void tc1_PageContent_CachedQueries() {
    this.log.info("tc1_PageContent_CachedQueries");

    wait.until(ExpectedConditions.titleContains("CDA Cache Manager"));
    assertEquals("CDA Cache Manager", driver.getTitle());
    //Go to Cached Queries
    WebElement buttonCachedQueries = this.elemHelper.FindElement(driver, By.id("cacheButton"));
    assertNotNull(buttonCachedQueries);
    buttonCachedQueries.click();

    /*
     * ## Step 1
     */
    String subTitle = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='cachedQueries']/div[3]"));
    assertEquals("Queries in cache", subTitle);

    /*
     * ## Step 2
     */
    String buttonTextClearCache = this.elemHelper.WaitForElementPresentGetText(driver,
            By.id("clearCacheButton"));
    assertEquals("Clear Cache", buttonTextClearCache);
}

From source file:com.pentaho.ctools.cde.reference.AddinReference.java

License:Apache License

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name:/*from w  w w.j a  va2  s .co  m*/
 *    Page Content
 * Description:
 *    The test case pretends to validate the display contents on the page.
 * Steps:
 *    1. Check display texts
 */
@Test
public void tc01_PageContent_ContentDisplayed() {
    this.log.info("tc01_PageContent_CachedQueries");

    /*
     * ## Step 1
     */
    //Check title
    wait.until(ExpectedConditions.titleContains("AddIn Reference"));
    assertEquals("AddIn Reference", driver.getTitle());

    //Check subtitle
    String textSubTitle1 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='Title']/span"));
    assertEquals("AddIns reference", textSubTitle1);

    //Check subtitle
    String textSubTitle2 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='DescriptionBody']/div"));
    assertEquals("AddIn Implementation", textSubTitle2);

    //Check subtitle
    String textSubTitle3 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='DescriptionBody']/div[2]"));
    assertEquals("Setting options", textSubTitle3);

    //Check subtitle
    String textSubTitle4 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='DescriptionBody']/div[3]"));
    assertEquals("Setting defaults", textSubTitle4);

    //Check subtitle
    String textSubTitle5 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='DescriptionBody']/div[4]"));
    assertEquals("Implementation arguments", textSubTitle5);

    //Check subtitle
    String textSubTitle6 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='DescriptionBody']/div[5]"));
    assertEquals("Calling AddIns from components", textSubTitle6);

    //Check subtitle
    String textSubTitle7 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='SupportedAddinsTitle']"));
    assertEquals("Supported AddIns - Table \"colType\"", textSubTitle7);
}