Example usage for org.openqa.selenium Keys ENTER

List of usage examples for org.openqa.selenium Keys ENTER

Introduction

In this page you can find the example usage for org.openqa.selenium Keys ENTER.

Prototype

Keys ENTER

To view the source code for org.openqa.selenium Keys ENTER.

Click Source Link

Usage

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

License:Apache License

/**
 * ############################### Test Case 3 ###############################
 *
 * Test Case Name://from w  w w  .  ja  v a 2 s  . co m
 *    Set Date Range Today
 * Description:
 *    When click on Today option an alert is displayed with today date in
 *    range interval.
 * Steps:
 *    1. Click in Today option
 *    2. Check for Alert
 */
@Test
public void tc3_Today_DateIsSetSuccessful() {
    this.log.info("tc3_Today_DateIsSetSuccessful");

    /*
     * ## Step 1
     */
    this.elemHelper.Click(driver, By.id("myInput"));
    //ADD THIS LINE TO RUN IN WIN8: this.elemHelper.Click( driver, By.id( "myInput2" ) );
    this.elemHelper.FindElement(driver, By.linkText("Today")).sendKeys(Keys.ENTER);

    /*
     * ## Step 2
     */
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date dNow = new Date();
    String strToday = sdf.format(dNow);

    String confirmationMsg = this.elemHelper.WaitForAlertReturnConfirmationMsg(driver);
    String expectedCnfText = "You chose from " + strToday + " to " + strToday;

    assertEquals(confirmationMsg, expectedCnfText);
}

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

License:Apache License

/**
 * ############################### Test Case 4 ###############################
 *
 * Test Case Name://from   w  ww .  ja v  a2  s  .  c  o  m
 *    Set Date Range for the Last Seven Days.
 * Description:
 *    When click on Last 7 Days option an alert is displayed with 7 days
 *    before today and the today date.
 * Steps:
 *    1. Click in Last 7 Days option
 *    2. Check for Alert
 */
@Test
public void tc4_LastSevenDays_DateIsSetSuccessful() {
    this.log.info("tc4_LastSevenDays_DateIsSetSuccessful");

    /*
     * ## Step 1
     */
    this.elemHelper.Click(driver, By.id("myInput"));
    //ADD THIS LINE TO RUN IN WIN8: this.elemHelper.Click( driver, By.id( "myInput2" ) );
    this.elemHelper.FindElement(driver, By.linkText("Last 7 days")).sendKeys(Keys.ENTER);

    /*
     * ## Step 2
     */
    Calendar c = Calendar.getInstance();
    c.add(Calendar.DAY_OF_MONTH, -7);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date dNow = new Date();
    String strToday = sdf.format(dNow);

    String confirmationMsg = this.elemHelper.WaitForAlertReturnConfirmationMsg(driver);
    String expectedCnfText = "You chose from " + sdf.format(c.getTime()) + " to " + strToday;

    assertEquals(confirmationMsg, expectedCnfText);
}

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

License:Apache License

/**
 * ############################### Test Case 5 ###############################
 *
 * Test Case Name:/*from  www . ja  v  a2  s .  co m*/
 *    Set Date Range Month to Today date
 * Description:
 *    When click on Month to date option an alert is displayed with begin
 *    month day to today date.
 * Steps:
 *    1. Click in Month to date option
 *    2. Check for Alert
 */
@Test
public void tc5_MonthToDate_DateIsSetSuccessful() {
    this.log.info("tc5_MonthToDate_DateIsSetSuccessful");

    /*
     * ## Step 1
     */
    this.elemHelper.Click(driver, By.id("myInput"));
    //ADD THIS LINE TO RUN IN WIN8: this.elemHelper.Click( driver, By.id( "myInput2" ) );
    this.elemHelper.FindElement(driver, By.linkText("Month to date")).sendKeys(Keys.ENTER);

    /*
     * ## Step 2
     */
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM");
    Date dNow = new Date();
    String strToday = sdf.format(dNow);
    String strCurrentMonth = sdfMonth.format(dNow) + "-01";

    String confirmationMsg = this.elemHelper.WaitForAlertReturnConfirmationMsg(driver);
    String expectedCnfText = "You chose from " + strCurrentMonth + " to " + strToday;

    assertEquals(confirmationMsg, expectedCnfText);
}

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

License:Apache License

/**
 * ############################### Test Case 6 ###############################
 *
 * Test Case Name:/*from w  w w  . j a  va  2s .c om*/
 *    Set Date Range Year To Date
 * Description:
 *    When click on Year To Date option an alert is displayed with begin year
 *    date to today date in range interval.
 * Steps:
 *    1. Click in Year to date option
 *    2. Check for Alert
 */
@Test
public void tc6_YearToDate_DateIsSetSuccessful() {
    this.log.info("tc6_YearToDate_DateIsSetSuccessful");

    /*
     * ## Step 1
     */
    this.elemHelper.Click(driver, By.id("myInput"));
    //ADD THIS LINE TO RUN IN WIN8: this.elemHelper.Click( driver, By.id( "myInput2" ) );
    this.elemHelper.FindElement(driver, By.linkText("Year to date")).sendKeys(Keys.ENTER);

    /*
     * ## Step 2
     */
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy");
    Date dNow = new Date();
    String strToday = sdf.format(dNow);
    String strBeginYear = sdfYear.format(dNow) + "-01-01";

    String confirmationMsg = this.elemHelper.WaitForAlertReturnConfirmationMsg(driver);
    String expectedCnfText = "You chose from " + strBeginYear + " to " + strToday;

    assertEquals(confirmationMsg, expectedCnfText);
}

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

License:Apache License

/**
 * ############################### Test Case 7 ###############################
 *
 * Test Case Name:/*from   w  w  w .jav a 2s  . c  om*/
 *    Set Date Range Today
 * Description:
 *    When click on The Previous Month option an alert is displayed with the
 *    start day of previous month to last day of previous month in range
 *    interval.
 * Steps:
 *    1. Click in The Previous Month option
 *    2. Check for Alert
 */
@Test
public void tc7_ThePreviousMonth_DateIsSetSuccessful() {
    this.log.info("tc7_ThePreviousMonth_DateIsSetSuccessful");

    /*
     * ## Step 1
     */
    this.elemHelper.Click(driver, By.id("myInput"));
    //ADD THIS LINE TO RUN IN WIN8: this.elemHelper.Click( driver, By.id( "myInput2" ) );
    this.elemHelper.FindElement(driver, By.linkText("The previous Month")).sendKeys(Keys.ENTER);

    /*
     * ## Step 2
     */
    Calendar c = Calendar.getInstance();
    c.add(Calendar.MONTH, -1);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");

    String strLastMonthEndDay = sdf.format(c.getTime());
    String strLastMonthStartDay = sdf.format(c.getTime()) + "-01";
    c.add(Calendar.MONTH, 1);
    c.add(Calendar.DAY_OF_MONTH, c.get(Calendar.DAY_OF_MONTH) * -1);
    strLastMonthEndDay += "-" + c.get(Calendar.DAY_OF_MONTH);

    String confirmationMsg = this.elemHelper.WaitForAlertReturnConfirmationMsg(driver);
    String expectedCnfText = "You chose from " + strLastMonthStartDay + " to " + strLastMonthEndDay;
    assertEquals(confirmationMsg, expectedCnfText);
}

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

License:Apache License

/**
 * ############################### Test Case 8 ###############################
 *
 * Test Case Name://www .  j a v a 2  s  . co m
 *    Set Date Range Today
 * Description:
 *    When click on All Dates Before option an alert is displayed with an 
 *    interval starting from '2014-04-22'  to the selected date.
 * Steps:
 *    1. Click in Today option and then Cancel
 *    2. Click in Today option and then Done
 *    3. Check for Alert
 */
@Test
public void tc8_AllDatesBeforePressCancelAndSelectDate_DateIsCancelAndThenSetSuccessful() {
    this.log.info("tc8_AllDatesBeforePressCancelAndSelectDate_DateIsCancelAndThenSetSuccessful");

    /*
     * ## Step 1
     */
    this.elemHelper.Click(driver, By.id("myInput"));
    this.elemHelper.FindElement(driver, By.linkText("All Dates Before")).sendKeys(Keys.ENTER);
    this.elemHelper.Click(driver, By.xpath("(//button[contains(text(),'Cancel')])[7]"));
    this.elemHelper.WaitForElementInvisibility(driver, By.xpath("(//a[text()='All Dates Before'])[2]"), 5);
    WebElement dataPickerDisable = this.elemHelper.WaitForElementPresence(driver,
            By.xpath("(//a[text()='All Dates Before'])[2]"), 1);
    assertFalse(dataPickerDisable.isDisplayed());

    /*
     * ## Step 2
     */
    //Click in day 29
    this.elemHelper.Click(driver, By.id("myInput"));
    //ADD THIS LINE TO RUN IN WIN8: this.elemHelper.Click( driver, By.id( "myInput2" ) );
    this.elemHelper.FindElement(driver, By.linkText("All Dates Before")).sendKeys(Keys.ENTER);
    this.elemHelper.FindElement(driver, By.linkText("29")).sendKeys(Keys.ENTER);

    /*
     * ## Step 3
     */
    String confirmationMsg = this.elemHelper.WaitForAlertReturnConfirmationMsg(driver);

    Calendar c = Calendar.getInstance();
    c.add(Calendar.YEAR, -1);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String beginDate = sdf.format(c.getTime());

    assertEquals(confirmationMsg, "You chose from " + beginDate + " to 2014-09-29");
}

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

License:Apache License

/**
 * ############################### Test Case 3 ###############################
 *
 * Test Case Name:/* ww w  .  java 2s. c om*/
 *    Check Paging
 * Description:
 *    User has the possibility to navigate between pages, and new date shall
 *    be displayed.
 * Steps:
 *    1. Check the data in first page is correct.
 *    2. Go to the next page and check the data.
 *    3. Go to the end page and check the data.
 *    4. Go to the first page and check the data.
 */
@Test
public void tc3_Paging_NavigateBetweenPages() {
    this.log.info("tc3_Paging_NavigateBetweenPages");

    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("sampleObjectTable_length")));
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("sampleObjectTable_filter")));
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("sampleObjectTable")));
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("sampleObjectTable_info")));
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("sampleObjectTable_paginate")));

    /*
     * ## Step 1
     */
    assertEquals("Showing 1 to 10 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='sampleObjectTable_info']")));
    assertEquals("Amica Models & Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td")));
    assertEquals("94,117", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]")));
    assertEquals("200,995", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]")));
    assertEquals("Baane Mini Imports", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td")));
    assertEquals("Cruz & Sons Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td")));
    assertEquals("94,016", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]")));

    /*
     * ## Step 2
     */
    //Where we press NEXT
    WebElement page2 = this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_next']"));
    assertNotNull(page2);
    page2.sendKeys(Keys.ENTER);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[2][@class='paginate_button current']")));
    assertEquals("Showing 11 to 20 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='sampleObjectTable_info']")));
    assertEquals("Danish Wholesale Imports", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td")));
    assertEquals("145,042", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]")));
    assertEquals("174,140", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]")));
    assertEquals("Extreme Desk Decorations, Ltd", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td")));
    assertEquals("Handji Gifts& Co", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td")));
    assertEquals("115,499", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]")));

    /*
     * ## Step 3
     */
    //Where we press 5
    WebElement page5 = this.elemHelper.FindElement(driver,
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[5]"));
    assertNotNull(page5);
    page5.sendKeys(Keys.ENTER);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[5][@class='paginate_button current']")));
    assertEquals("Showing 41 to 50 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='sampleObjectTable_info']")));
    assertEquals("Suominen Souveniers", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td")));
    assertEquals("113,961", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]")));
    assertEquals("160,010", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]")));
    assertEquals("Toys of Finland, Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td")));
    assertEquals("Vitachrome Inc.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td")));
    assertEquals("88,041", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]")));

    //## Step 4
    this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_previous']")).sendKeys(Keys.ENTER);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[4][@class='paginate_button current']")));
    this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_previous']")).sendKeys(Keys.ENTER);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[3][@class='paginate_button current']")));
    this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_previous']")).sendKeys(Keys.ENTER);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[2][@class='paginate_button current']")));
    this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_previous']")).sendKeys(Keys.ENTER);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[@class='paginate_button current']")));

    assertEquals("Showing 1 to 10 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='sampleObjectTable_info']")));
    assertEquals("Amica Models & Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td")));
    assertEquals("94,117", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]")));
    assertEquals("200,995", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]")));
    assertEquals("Baane Mini Imports", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td")));
    assertEquals("Cruz & Sons Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td")));
    assertEquals("94,016", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]")));
}

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

License:Apache License

/**
 * ############################### Test Case 4 ###############################
 *
 * Test Case Name://from  ww w. java  2  s. c o m
 *    Sort
 * Description:
 *    Testing the sort on Customer and Sales, and when user is not in the
 *    first page.
 * Steps:
 *    1. Sort in Customer (Desc)
 *    2. Sort in Sales (Asc)
 *    3. Page to the third page
 *    4. Sort in Sales (Desc)
 *    5. Go to the next page and check the data.
 *    6. Go to the end page and check the data.
 *    7. Go to the first page and check the data.
 */
@Test
public void tc4_Sort_ElementsAreSort() {
    this.log.info("tc4_Sort_ElementsAreSort");

    /*
     * ## Step 1
     */
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//table[@id='sampleObjectTable']/thead/tr/th[@class='column0 string sorting_asc']")));
    this.elemHelper.FindElement(driver, By.xpath("//table[@id='sampleObjectTable']/thead/tr/th")).click(); //Set to DESC
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//table[@id='sampleObjectTable']/thead/tr/th[@class='column0 string sorting_desc']")));
    //Check Data
    assertNotNull(this.elemHelper.FindElement(driver,
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1][@class='paginate_button current']")));
    assertEquals("Showing 1 to 10 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='sampleObjectTable_info']")));
    assertEquals("Vitachrome Inc.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td")));
    assertEquals("88,041", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]")));
    assertEquals("118,008", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]")));
    assertTrue(this.elemHelper
            .WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))
            .contains("Toms"));
    assertEquals("Suominen Souveniers", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td")));
    assertEquals("113,961", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]")));

    /*
     * ## Step 2
     */
    this.elemHelper.FindElement(driver, By.xpath("//table[@id='sampleObjectTable']/thead/tr/th[2]")).click(); //Sort Sales to ASC
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//table[@id='sampleObjectTable']/thead/tr/th[2][@class='column1 numeric sorting_asc']")));
    //Check Data
    assertNotNull(this.elemHelper.FindElement(driver,
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1][@class='paginate_button current']")));
    assertEquals("Showing 1 to 10 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='sampleObjectTable_info']")));
    assertEquals("Collectable Mini Designs Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td")));
    assertEquals("87,489", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]")));
    assertEquals("88,805", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]")));
    assertEquals("Amica Models & Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td")));
    assertTrue(this.elemHelper
            .WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))
            .contains("Toms"));
    assertEquals("100,307", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]")));

    /*
     * ## Step 3
     */
    WebElement page3 = this.elemHelper.FindElement(driver,
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[3]"));
    assertNotNull(page3);
    page3.sendKeys(Keys.ENTER);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[3][@class='paginate_button current']")));
    //Check Data
    assertNotNull(this.elemHelper.FindElement(driver,
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[3][@class='paginate_button current']")));
    assertEquals("Showing 21 to 30 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='sampleObjectTable_info']")));
    assertEquals("Handji Gifts& Co", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td")));
    assertEquals("115,499", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]")));
    assertEquals("117,714", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]")));
    assertEquals("Corrida Auto Replicas, Ltd", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td")));
    assertEquals("Scandinavian Gift Ideas", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td")));
    assertEquals("134,259", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]")));

    /*
     * ## Step 4
     */
    this.elemHelper.FindElement(driver, By.xpath("//table[@id='sampleObjectTable']/thead/tr/th[2]")).click(); //Sort Sales to DESC
    wait.until(ExpectedConditions.visibilityOfElementLocated(By
            .xpath("//table[@id='sampleObjectTable']/thead/tr/th[2][@class='column1 numeric sorting_desc']")));
    //Check Data
    assertNotNull(this.elemHelper.FindElement(driver,
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1][@class='paginate_button current']")));
    assertEquals("Showing 1 to 10 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='sampleObjectTable_info']")));
    assertEquals("Euro+ Shopping Channel", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td")));
    assertEquals("912,294", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]")));
    assertEquals("200,995", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]")));
    assertEquals("Down Under Souveniers, Inc", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td")));
    assertEquals("Kelly's Gift Shop", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td")));
    assertEquals("158,345", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]")));

    /*
     * ## Step 5
     */
    WebElement page2 = this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_next']"));
    assertNotNull(page2);
    page2.sendKeys(Keys.ENTER);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[2][@class='paginate_button current']")));
    assertNotNull(this.elemHelper.FindElement(driver,
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[2][@class='paginate_button current']")));
    assertEquals("Showing 11 to 20 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='sampleObjectTable_info']")));
    assertEquals("AV Stores, Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td")));
    assertEquals("157,808", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]")));
    assertEquals("151,571", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]")));
    assertEquals("Danish Wholesale Imports", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td")));
    assertEquals("Reims Collectables", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td")));
    assertEquals("135,043", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]")));

    /*
     * ## Step 6
     */
    this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_next']")).sendKeys(Keys.ENTER);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[3][@class='paginate_button current']")));
    this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_next']")).sendKeys(Keys.ENTER);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[4][@class='paginate_button current']")));
    this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_next']")).sendKeys(Keys.ENTER);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[5][@class='paginate_button current']")));
    assertNotNull(this.elemHelper.FindElement(driver,
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[5][@class='paginate_button current']")));
    assertEquals("Showing 41 to 50 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='sampleObjectTable_info']")));
    assertTrue(this.elemHelper
            .WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))
            .contains("Toms"));
    assertEquals("100,307", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]")));
    assertEquals("98,496", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]")));
    assertEquals("Cruz & Sons Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td")));
    assertEquals("Collectable Mini Designs Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td")));
    assertEquals("87,489", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]")));

    /*
     * ## Step 7
     */
    WebElement page1 = this.elemHelper.FindElement(driver,
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1]"));
    assertNotNull(page1);
    page1.sendKeys(Keys.ENTER);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1][@class='paginate_button current']")));
    //Check Data
    assertNotNull(this.elemHelper.FindElement(driver,
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1][@class='paginate_button current']")));
    assertEquals("Showing 1 to 10 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='sampleObjectTable_info']")));
    assertEquals("Euro+ Shopping Channel", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td")));
    assertEquals("912,294", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]")));
    assertEquals("200,995", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]")));
    assertEquals("Down Under Souveniers, Inc", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td")));
    assertEquals("Kelly's Gift Shop", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td")));
    assertEquals("158,345", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]")));

    //reset to initial state
    this.elemHelper.FindElement(driver, By.xpath("//table[@id='sampleObjectTable']/thead/tr/th")).click(); //Set Customers to ASC
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//table[@id='sampleObjectTable']/thead/tr/th[@class='column0 string sorting_asc']")));
    assertEquals("Showing 1 to 10 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='sampleObjectTable_info']")));
    assertEquals("Amica Models & Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td")));
    assertEquals("94,117", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]")));
    assertEquals("200,995", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]")));
    assertEquals("Baane Mini Imports", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td")));
    assertEquals("Cruz & Sons Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td")));
    assertEquals("94,016", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]")));
}

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

License:Apache License

/**
 * ############################### Test Case 6 ###############################
 *
 * Test Case Name://from   w w w  .  j  a  v  a 2s . c o m
 *    Search Engine
 * Description:
 *    When search for something the table is refresh with the contents
 *    searched.
 * Steps:
 *    1. Search for 'Co.' (Check paging, display entries, sort)
 *    2. Search for 'Euro' (Check paging, display entries, sort)
 *    3. Search for 'TODO' (no result)
 */
@Test
public void tc6_SearchEngine_TableDisplayedContentSearch() {
    this.log.info("tc6_SearchEngine_TableDisplayedContentSearch");

    /*
     * ## Step 1
     */
    this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_filter']/label/input"))
            .sendKeys("Co.");
    assertEquals("Showing 1 to 10 of 13 entries (filtered from 50 total entries)", this.elemHelper
            .WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']")));
    assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_previous")).isDisplayed());
    assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_previous")).isEnabled());
    assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_next")).isDisplayed());
    assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_next")).isEnabled());
    //check paging 1 and 2
    assertTrue(this.elemHelper
            .FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1]")).isEnabled());
    assertTrue(this.elemHelper
            .FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1]")).isDisplayed());
    assertTrue(this.elemHelper
            .FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[2]")).isEnabled());
    assertTrue(this.elemHelper
            .FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[2]")).isDisplayed());
    assertEquals("Amica Models & Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td")));
    assertEquals("94,117", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]")));
    assertEquals("157,808", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]")));
    assertEquals("Cruz & Sons Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td")));
    assertEquals("Saveley & Henriot, Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td")));
    assertEquals("142,874", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]")));
    //Click Next
    this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_next']")).sendKeys(Keys.ENTER);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[2][@class='paginate_button current']")));
    assertEquals("Souveniers And Things Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[1]/td")));
    assertEquals("Toys of Finland, Co.", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td")));
    assertEquals("111,250", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]")));

    /*
     * ## Step 2
     */
    this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_filter']/label/input")).clear();
    this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_filter']/label/input"))
            .sendKeys("Euro");
    assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_previous")).isDisplayed());
    assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_previous")).isEnabled());
    assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_next")).isDisplayed());
    assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_next")).isEnabled());
    assertTrue(this.elemHelper
            .FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1]")).isEnabled());
    assertTrue(this.elemHelper
            .FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1]")).isDisplayed());
    assertTrue(this.elemHelper.WaitForElementNotPresent(driver,
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[2]"), 2));
    assertEquals("Showing 1 to 1 of 1 entries (filtered from 50 total entries)", this.elemHelper
            .WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']")));
    assertEquals("Euro+ Shopping Channel", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td")));
    assertEquals("912,294", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]")));

    //## Step 3
    this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_filter']/label/input")).clear();
    this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_filter']/label/input"))
            .sendKeys("TODO");
    assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_previous")).isDisplayed());
    assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_previous")).isEnabled());
    assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_next")).isDisplayed());
    assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_next")).isEnabled());
    assertTrue(this.elemHelper.WaitForElementNotPresent(driver,
            By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1]"), 2));
    assertEquals("Showing 0 to 0 of 0 entries (filtered from 50 total entries)", this.elemHelper
            .WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']")));
    assertEquals("No matching records found", this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td")));
}

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

License:Apache License

/**
 * ############################### Test Case 3 ###############################
 *
 * Test Case Name:/*w w  w.j  a v  a 2 s.co  m*/
 *    Insert a small text
 * Description:
 *    We pretend validate when we insert a small text an alert is raised.
 * Steps:
 *    1. Insert text
 *    2. Check for alert
 *    3. Check the input text inserted
 */
@Test
public void tc3_InputSmallPhrase_AlertDispayed() {
    this.log.info("tc3_InputSmallPhrase_AlertDispayed");

    /*
     * ## Step 1
     */
    String strInputString = "Hello World!";
    this.elemHelper.FindElement(driver, By.id("myInput")).clear();
    this.elemHelper.FindElement(driver, By.id("myInput")).sendKeys(strInputString);
    this.elemHelper.FindElement(driver, By.id("myInput")).sendKeys(Keys.ENTER);

    /*
     * ## Step 2
     */
    wait.until(ExpectedConditions.alertIsPresent());
    Alert alert = driver.switchTo().alert();
    String confirmationMsg = alert.getText();
    String expectedCnfText = "you typed: " + strInputString;
    alert.accept();

    assertEquals(expectedCnfText, confirmationMsg);
}