Example usage for org.openqa.selenium WebElement sendKeys

List of usage examples for org.openqa.selenium WebElement sendKeys

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement sendKeys.

Prototype

void sendKeys(CharSequence... keysToSend);

Source Link

Document

Use this method to simulate typing into an element, which may set its value.

Usage

From source file:com.pentaho.ctools.cdf.require.samples.Xmla.java

License:Apache License

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name:/* w w w.ja v  a 2  s.co m*/
 *    Assert query results for XMLA first sample
 */
@Test
public void tc1_XmlaQueryEnable_CheckForEnable() {
    this.log.info("tc1_XmlaQueryEnable_CheckForEnable");
    //To set up this test we must enable xmla for SteelWheels datasource
    this.elemHelper.Get(driver, PageUrl.PUC);

    // NOTE - we have to wait for loading disappear
    this.elemHelper.WaitForElementPresence(driver, By.cssSelector("div.busy-indicator-container.waitPopup"),
            20);
    this.elemHelper.WaitForElementNotPresent(driver, By.cssSelector("div.busy-indicator-container.waitPopup"));
    //Wait to load the new page
    this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//div[@id='pucUserDropDown']/table/tbody/tr/td/div"));
    this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//iframe[@id='home.perspective']"));

    //Open File menu and select Manage Data Sources
    WebElement fileMenu = this.elemHelper.FindElement(driver, By.id("filemenu"));
    assertNotNull(fileMenu);
    fileMenu.click();
    WebElement manageSources = this.elemHelper.FindElement(driver, By.id("manageDatasourceItem"));
    assertNotNull(manageSources);
    manageSources.click();
    //Wait for datasources popup to open click "SteelWheels Analysis" and click edit
    WebElement dataPopup = this.elemHelper.FindElement(driver, By.xpath("//div[@class='pentaho-dialog']"));
    assertNotNull(dataPopup);
    WebElement steelSource = this.elemHelper.FindElement(driver,
            By.xpath("//div[@class='pentaho-dialog']//tbody//div[contains(text(),'SteelWheels')]"));
    assertNotNull(steelSource);
    steelSource.click();
    WebElement settingsButton = this.elemHelper.FindElement(driver,
            By.xpath("//div[@class='pentaho-dialog']//div[@id='datasourceDropdownButton']/img"));
    assertNotNull(settingsButton);
    settingsButton.click();
    WebElement optionsPopup = this.elemHelper.FindElement(driver, By.xpath("//div[@class='popupContent']"));
    assertNotNull(optionsPopup);
    WebElement editButton = this.elemHelper.FindElement(driver,
            By.xpath("//div[@class='popupContent']//td[contains(text(),'Edit...')]"));
    assertNotNull(editButton);
    editButton.click();

    //On new popup select "Manual enter" and set Enable Xmla as true
    WebElement manualButton = this.elemHelper.FindElement(driver,
            By.xpath("//table[@id='manualRadio']//input"));
    assertNotNull(manualButton);
    this.elemHelper.ClickJS(driver, By.xpath("//table[@id='manualRadio']//input"));
    //Check if is already "TRUE"
    String setAsTrue = this.elemHelper.WaitForTextDifferentEmpty(driver,
            By.xpath("//div[@id='analysisParametersTree']//div[2]//tr[3]/td[2]"));
    if (setAsTrue.equalsIgnoreCase("true")) {
        assertEquals(setAsTrue, "true");
    } else {
        WebElement enableXmla = this.elemHelper.FindElement(driver,
                By.xpath("//div[@id='analysisPreferencesDeck']//div[contains(text(),'EnableXmla')]"));
        assertNotNull(enableXmla);
        enableXmla.click();
        WebElement editXmla = this.elemHelper.FindElement(driver, By.xpath("//div[@id='editutton']/img"));
        assertNotNull(editXmla);
        editXmla.click();
        WebElement editXmlaInput = this.elemHelper.FindElement(driver, By.id("paramValueTextBox"));
        assertNotNull(editXmlaInput);
        editXmlaInput.clear();
        editXmlaInput.sendKeys("true");
        WebElement okButton = this.elemHelper.FindElement(driver, By.id("analysisParametersDialog_accept"));
        assertNotNull(okButton);
        okButton.click();
        this.elemHelper.WaitForElementNotPresent(driver, By.xpath("//div[@class='pentaho-dialog'][3]"));
        setAsTrue = this.elemHelper
                .FindElement(driver, By.xpath("//div[@id='analysisParametersTree']//div[2]//tr[3]/td[2]"))
                .getText();
        assertEquals(setAsTrue, "true");
        WebElement saveButton = this.elemHelper.FindElementInvisible(driver, By.id("importDialog_accept"));
        assertNotNull(saveButton);
        this.elemHelper.ClickElementInvisible(driver, By.id("importDialog_accept"));
        this.elemHelper.WaitForElementNotPresent(driver, By.id("importDialog_accept"));
        WebElement closeButton = this.elemHelper.FindElement(driver, By.id("datasourceAdminDialog_cancel"));
        assertNotNull(closeButton);
        closeButton.click();
        this.elemHelper.WaitForElementNotPresent(driver, By.id("datasourceAdminDialog_cancel"));
    }
}

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

License:Apache License

/**
 * ############################### Test Case 3 ###############################
 *
 * Test Case Name://  ww w .  j av a 2s.c  o  m
 *    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:/*w w  w.j ava2 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.samples.Xmla.java

License:Apache License

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name://from   w  w w  .j  a  v a  2 s .  c  o  m
 *    Assert query results for XMLA first sample
 */
@Test
public void tc1_XmlaQueryEnable_CheckForEnable() {
    this.log.info("tc1_XmlaQueryEnable_CheckForEnable");
    //To set up this test we must enable xmla for SteelWheels datasource
    this.elemHelper.Get(driver, PageUrl.PUC);

    // NOTE
    //wait for visibility of waiting pop-up
    this.elemHelper.WaitForElementPresence(driver, By.cssSelector("div.busy-indicator-container.waitPopup"),
            20);
    this.elemHelper.WaitForElementNotPresent(driver, By.cssSelector("div.busy-indicator-container.waitPopup"));
    //Wait to load the new page
    this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//div[@id='pucUserDropDown']/table/tbody/tr/td/div"));
    this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//iframe[@id='home.perspective']"));

    //Open File menu and select Manage Data Sources
    WebElement fileMenu = this.elemHelper.FindElement(driver, By.id("filemenu"));
    assertNotNull(fileMenu);
    fileMenu.click();
    WebElement manageSources = this.elemHelper.FindElement(driver, By.id("manageDatasourceItem"));
    assertNotNull(manageSources);
    manageSources.click();
    //Wait for datasources popup to open click "SteelWheels Analysis" and click edit
    WebElement dataPopup = this.elemHelper.FindElement(driver, By.xpath("//div[@class='pentaho-dialog']"));
    assertNotNull(dataPopup);
    WebElement steelSource = this.elemHelper.FindElement(driver,
            By.xpath("//div[@class='pentaho-dialog']//tbody//div[contains(text(),'SteelWheels')]"));
    assertNotNull(steelSource);
    steelSource.click();
    WebElement settingsButton = this.elemHelper.FindElement(driver,
            By.xpath("//div[@class='pentaho-dialog']//div[@id='datasourceDropdownButton']/img"));
    assertNotNull(settingsButton);
    settingsButton.click();
    WebElement optionsPopup = this.elemHelper.FindElement(driver, By.xpath("//div[@class='popupContent']"));
    assertNotNull(optionsPopup);
    WebElement editButton = this.elemHelper.FindElement(driver,
            By.xpath("//div[@class='popupContent']//td[contains(text(),'Edit...')]"));
    assertNotNull(editButton);
    editButton.click();

    //On new popup select "Manual enter" and set Enable Xmla as true
    WebElement manualButton = this.elemHelper.FindElement(driver,
            By.xpath("//table[@id='manualRadio']//input"));
    assertNotNull(manualButton);
    this.elemHelper.ClickJS(driver, By.xpath("//table[@id='manualRadio']//input"));
    //Check if is already "TRUE"
    String setAsTrue = this.elemHelper.WaitForTextDifferentEmpty(driver,
            By.xpath("//div[@id='analysisParametersTree']//div[2]//tr[3]/td[2]"));
    if (setAsTrue.equalsIgnoreCase("true")) {
        assertEquals(setAsTrue, "true");
    } else {
        WebElement enableXmla = this.elemHelper.FindElement(driver,
                By.xpath("//div[@id='analysisPreferencesDeck']//div[contains(text(),'EnableXmla')]"));
        assertNotNull(enableXmla);
        enableXmla.click();
        WebElement editXmla = this.elemHelper.FindElement(driver, By.xpath("//div[@id='editutton']/img"));
        assertNotNull(editXmla);
        editXmla.click();
        WebElement editXmlaInput = this.elemHelper.FindElement(driver, By.id("paramValueTextBox"));
        assertNotNull(editXmlaInput);
        editXmlaInput.clear();
        editXmlaInput.sendKeys("true");
        WebElement okButton = this.elemHelper.FindElement(driver, By.id("analysisParametersDialog_accept"));
        assertNotNull(okButton);
        okButton.click();
        this.elemHelper.WaitForElementNotPresent(driver, By.xpath("//div[@class='pentaho-dialog'][3]"));
        setAsTrue = this.elemHelper
                .FindElement(driver, By.xpath("//div[@id='analysisParametersTree']//div[2]//tr[3]/td[2]"))
                .getText();
        assertEquals(setAsTrue, "true");
        WebElement saveButton = this.elemHelper.FindElementInvisible(driver, By.id("importDialog_accept"));
        assertNotNull(saveButton);
        this.elemHelper.ClickElementInvisible(driver, By.id("importDialog_accept"));
        this.elemHelper.WaitForElementNotPresent(driver, By.id("importDialog_accept"));
        WebElement closeButton = this.elemHelper.FindElement(driver, By.id("datasourceAdminDialog_cancel"));
        assertNotNull(closeButton);
        closeButton.click();
        this.elemHelper.WaitForElementNotPresent(driver, By.id("datasourceAdminDialog_cancel"));
    }
}