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

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

Introduction

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

Prototype

public static ExpectedCondition<WebElement> visibilityOfElementLocated(final By locator) 

Source Link

Document

An expectation for checking that an element is present on the DOM of a page and visible.

Usage

From source file:com.pentaho.ctools.cdf.JFreeChartComponent.java

License:Apache License

/**
 * ############################### Test Case 2 ###############################
 *
 * Test Case Name:/*ww w  .  jav  a 2s .  co m*/
 *    Reload Sample
 * Description:
 *    Reload the sample (not refresh page).
 * Steps:
 *    1. Click in Code and then click in button 'Try me'.
 */
@Test
public void tc1_PageContent_DisplayTitle() {
    this.log.info("tc1_PageContent_DisplayTitle");
    // Wait for title become visible and with value 'Community Dashboard Framework'
    wait.until(ExpectedConditions.titleContains("Community Dashboard Framework"));
    // Wait for visibility of 'VisualizationAPIComponent'
    wait.until(ExpectedConditions
            .visibilityOfElementLocated(By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]")));

    // Validate the sample that we are testing is the one
    assertEquals("Community Dashboard Framework", driver.getTitle());
    assertEquals("jFreeChartComponent", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]")));
}

From source file:com.pentaho.ctools.cdf.MonthPickerComponent.java

License:Apache License

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name://from   w  w w . j a va2  s . c  om
 *    Reload Sample
 * Description:
 *    Reload the sample (not refresh page).
 * Steps:
 *    1. Click in Code and then click in button 'Try me'.
 */
@Test
public void tc1_PageContent_DisplayTitle() {
    this.log.info("tc1_PageContent_DisplayTitle");
    // Wait for title become visible and with value 'Community Dashboard Framework'
    wait.until(ExpectedConditions.titleContains("Community Dashboard Framework"));
    // Wait for visibility of 'VisualizationAPIComponent'
    wait.until(ExpectedConditions
            .visibilityOfElementLocated(By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]")));

    // Validate the sample that we are testing is the one
    assertEquals("Community Dashboard Framework", driver.getTitle());
    assertEquals("MonthPickerComponent", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]")));
}

From source file:com.pentaho.ctools.cdf.MultiButtonComponent.java

License:Apache License

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name://from w  ww  .  j  a  va2s. c o  m
 *    Reload Sample
 * Description:
 *    Reload the sample (not refresh page).
 * Steps:
 *    1. Click in Code and then click in button 'Try me'.
 */
@Test
public void tc1_PageContent_DisplayTitle() {
    this.log.info("tc1_PageContent_DisplayTitle");
    // Wait for title become visible and with value 'Community Dashboard Framework'
    wait.until(ExpectedConditions.titleContains("Community Dashboard Framework"));
    // Wait for visibility of 'VisualizationAPIComponent'
    wait.until(ExpectedConditions
            .visibilityOfElementLocated(By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]")));

    // Validate the sample that we are testing is the one
    assertEquals("Community Dashboard Framework", driver.getTitle());
    assertEquals("MultiButtonComponent", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]")));
}

From source file:com.pentaho.ctools.cdf.OpenFlashChartComponent.java

License:Apache License

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name:/*w w w .ja va2s. c om*/
 *    Reload Sample
 * Description:
 *    Reload the sample (not refresh page).
 * Steps:
 *    1. Click in Code and then click in button 'Try me'.
 */
@Test
public void tc1_PageContent_DisplayTitle() {
    this.log.info("tc1_PageContent_DisplayTitle");

    // Wait for title become visible and with value 'Community Dashboard Framework'
    wait.until(ExpectedConditions.titleContains("Community Dashboard Framework"));
    // Wait for visibility of 'VisualizationAPIComponent'
    wait.until(ExpectedConditions
            .visibilityOfElementLocated(By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]")));

    // Validate the sample that we are testing is the one
    assertEquals("Community Dashboard Framework", driver.getTitle());
    assertEquals("OpenFlashChartComponent", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]")));
}

From source file:com.pentaho.ctools.cdf.PrptComponent.java

License:Apache License

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name://from   w  w  w . j  a  va 2 s  .  c om
 *    Display Content
 * Description:
 *    Check if the contents present in page is the expected.
 * Steps:
 *    1. Check title web page and sample title.
 */
@Test
public void tc1_PageContent_DisplayTitle() {
    this.log.info("tc1_PageContent_DisplayTitle");
    // Wait for title become visible and with value 'Community Dashboard Framework'
    wait.until(ExpectedConditions.titleContains("Community Dashboard Framework"));
    // Wait for visibility of 'VisualizationAPIComponent'
    wait.until(ExpectedConditions
            .visibilityOfElementLocated(By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]")));

    // Validate the sample that we are testing is the one
    assertEquals("Community Dashboard Framework", driver.getTitle());
    assertEquals("PrptComponent", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]")));
}

From source file:com.pentaho.ctools.cdf.QueryComponent.java

License:Apache License

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name://w  w w.j  a v a2  s  .  co  m
 *    Reload Sample
 * Description:
 *    Reload the sample (not refresh page).
 * Steps:
 *    1. Click in Code and then click in button 'Try me'.
 */
@Test
public void tc1_PageContent_DisplayTitle() {
    this.log.info("tc1_PageContent_DisplayTitle");

    // Wait for title become visible and with value 'Community Dashboard Framework'
    wait.until(ExpectedConditions.titleContains("Community Dashboard Framework"));
    // Wait for visibility of 'VisualizationAPIComponent'
    wait.until(ExpectedConditions
            .visibilityOfElementLocated(By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]")));

    // Validate the sample that we are testing is the one
    assertEquals("Community Dashboard Framework", driver.getTitle());
    assertEquals("QueryComponent", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]")));
}

From source file:com.pentaho.ctools.cdf.RadioComponent.java

License:Apache License

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name:/*ww w  .j  a  v a  2  s.  c o m*/
 *    Reload Sample
 * Description:
 *    Reload the sample (not refresh page).
 * Steps:
 *    1. Click in Code and then click in button 'Try me'.
 */
@Test
public void tc1_PageContent_DisplayTitle() {
    this.log.info("tc1_PageContent_DisplayTitle");

    // wait for title become visible and with value 'Community Dashboard Framework'
    wait.until(ExpectedConditions.titleContains("Community Dashboard Framework"));
    // wait for visibility of 'VisualizationAPIComponent'
    wait.until(ExpectedConditions
            .visibilityOfElementLocated(By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]")));

    // Validate the sample that we are testing is the one
    assertEquals("Community Dashboard Framework", driver.getTitle());
    assertEquals("RadioComponent", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]")));
}

From source file:com.pentaho.ctools.cdf.RadioComponent.java

License:Apache License

/**
 * ############################### Test Case 3 ###############################
 *
 * Test Case Name:/*from   www.  j a  v a 2 s .  com*/
 *    Select options one by one
 * Description:
 *    We pretend validate the selection of each option one by one.
 * Steps:
 *    1. Select Eastern
 *    2. Select Central
 *    3. Select Western
 *    4. Select Southern
 */
@Test
public void tc3_SelectEachItem_AlertDisplayed() {
    this.log.info("tc3_SelectEachItem_AlertDisplayed");

    // ## Step 1
    assertTrue(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Southern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Eastern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Central']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Western']")).isSelected());
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@value='Eastern']")));
    this.elemHelper.FindElement(driver, By.xpath("//input[@value='Eastern']")).click();
    wait.until(ExpectedConditions.alertIsPresent());
    Alert alert = driver.switchTo().alert();
    String confirmationMsg = alert.getText();
    alert.accept();
    assertEquals("you chose: Eastern", confirmationMsg);
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Southern']")).isSelected());
    assertTrue(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Eastern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Central']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Western']")).isSelected());

    // ## Step 2
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@value='Central']")));
    this.elemHelper.FindElement(driver, By.xpath("//input[@value='Central']")).click();
    wait.until(ExpectedConditions.alertIsPresent());
    alert = driver.switchTo().alert();
    confirmationMsg = alert.getText();
    alert.accept();
    assertEquals("you chose: Central", confirmationMsg);
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Southern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Eastern']")).isSelected());
    assertTrue(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Central']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Western']")).isSelected());

    // ## Step 3
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@value='Western']")));
    this.elemHelper.FindElement(driver, By.xpath("//input[@value='Western']")).click();
    wait.until(ExpectedConditions.alertIsPresent());
    alert = driver.switchTo().alert();
    confirmationMsg = alert.getText();
    alert.accept();
    assertEquals("you chose: Western", confirmationMsg);
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Southern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Eastern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Central']")).isSelected());
    assertTrue(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Western']")).isSelected());

    // ## Step 4
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@value='Southern']")));
    this.elemHelper.FindElement(driver, By.xpath("//input[@value='Southern']")).click();
    wait.until(ExpectedConditions.alertIsPresent());
    alert = driver.switchTo().alert();
    confirmationMsg = alert.getText();
    alert.accept();
    assertEquals("you chose: Southern", confirmationMsg);
    assertTrue(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Southern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Eastern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Central']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Western']")).isSelected());
}

From source file:com.pentaho.ctools.cdf.RadioComponent.java

License:Apache License

/**
 * ############################### Test Case 4 ###############################
 *
 * Test Case Name:/*w ww. ja  v a  2  s .com*/
 *    Select arbitrary options
 * Description:
 *    We pretend validate the selection every available options but arbitrary.
 * Steps:
 *    1. Select Western
 *    2. Select Southern
 *    3. Select Central
 *    4. Select Western
 */
@Test
public void tc4_SelectArbitrary_AlertDisplayed() {
    this.log.info("tc4_SelectArbitrary_AlertDisplayed");

    // ## Step 1
    assertTrue(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Southern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Eastern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Central']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Western']")).isSelected());
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@value='Western']")));
    this.elemHelper.FindElement(driver, By.xpath("//input[@value='Western']")).click();
    wait.until(ExpectedConditions.alertIsPresent());
    Alert alert = driver.switchTo().alert();
    String confirmationMsg = alert.getText();
    alert.accept();
    assertEquals("you chose: Western", confirmationMsg);
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Southern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Eastern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Central']")).isSelected());
    assertTrue(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Western']")).isSelected());

    // ## Step 2
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@value='Southern']")));
    this.elemHelper.FindElement(driver, By.xpath("//input[@value='Southern']")).click();
    wait.until(ExpectedConditions.alertIsPresent());
    alert = driver.switchTo().alert();
    confirmationMsg = alert.getText();
    alert.accept();
    assertEquals("you chose: Southern", confirmationMsg);
    assertTrue(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Southern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Eastern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Central']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Western']")).isSelected());

    // ## Step 3
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@value='Central']")));
    this.elemHelper.FindElement(driver, By.xpath("//input[@value='Central']")).click();
    wait.until(ExpectedConditions.alertIsPresent());
    alert = driver.switchTo().alert();
    confirmationMsg = alert.getText();
    alert.accept();
    assertEquals("you chose: Central", confirmationMsg);
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Southern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Eastern']")).isSelected());
    assertTrue(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Central']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Western']")).isSelected());

    // ## Step 4
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@value='Western']")));
    this.elemHelper.FindElement(driver, By.xpath("//input[@value='Western']")).click();
    wait.until(ExpectedConditions.alertIsPresent());
    alert = driver.switchTo().alert();
    confirmationMsg = alert.getText();
    alert.accept();
    assertEquals("you chose: Western", confirmationMsg);
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Southern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Eastern']")).isSelected());
    assertFalse(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Central']")).isSelected());
    assertTrue(this.elemHelper.FindElement(driver, By.xpath("//input[@value='Western']")).isSelected());
}

From source file:com.pentaho.ctools.cdf.require.ExecutePrptComponent.java

License:Apache License

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name:/*  www. j  av a  2s . co  m*/
 *    Display Content
 * Description:
 *    Check if the contents present in page is the expected.
 * Steps:
 *    1. Check title web page and sample title.
 */
@Test
public void tc1_PageContent_DisplayTitle() {
    this.log.info("tc1_PageContent_DisplayTitle");

    // Wait for title become visible and with value 'Community Dashboard Framework'
    wait.until(ExpectedConditions.titleContains("Community Dashboard Framework"));
    // Wait for visibility of 'VisualizationAPIComponent'
    wait.until(ExpectedConditions
            .visibilityOfElementLocated(By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]")));

    // Validate the sample that we are testing is the one
    assertEquals("Community Dashboard Framework", driver.getTitle());
    assertEquals("ExecutePrptComponent", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]")));
}