Example usage for org.openqa.selenium By linkText

List of usage examples for org.openqa.selenium By linkText

Introduction

In this page you can find the example usage for org.openqa.selenium By linkText.

Prototype

public static By linkText(String linkText) 

Source Link

Usage

From source file:com.pearson.uitest.pageobjects.EditDataSettingsPage.java

public WebElement getOrganizationNameLink(String orgName) {
    return getElement(By.linkText(orgName));
}

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

License:Apache License

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name:/*from  ww w  .ja v  a 2s  .  co m*/
 *    Datasource Test
 * Description:
 *    The test case pretends to validate the return result of each query.
 * Steps:
 *    1. Check the result displayed
 */
@Test
public void tc1_DatasourceTest_ResultOK() {
    this.log.info("tc1_DatasourceTest_ResultOK");

    /*
     * Step 0 - Go to web page.
     */
    //Go to the CDA Cache Manager web page.
    driver.get(PageUrl.DATASOURCE_TEST);
    //wait for element to be visible
    this.elemHelper.WaitForElementVisibility(driver, By.xpath("//table[@id='testTable']/tbody/tr[15]/td"));
    // NOTE - we have to wait for loading disappear
    this.elemHelper.WaitForElementInvisibility(driver, By.cssSelector("div.blockUI.blockOverlay"));

    //Test About
    String urlAbout = this.elemHelper.FindElement(driver, By.linkText("About")).getAttribute("href");
    assertEquals(HttpStatus.SC_OK,
            HttpUtils.GetResponseCode(urlAbout, pentahoBaServerUsername, pentahoBaServerPassword));

    //sqk,jdbc
    String accessMethod1 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[2]/td"));
    String sample1 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[2]/td[3]/a"));
    WebElement element1 = this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[2]/td[4]/img[@src='resources/ok.png']"));
    //sql.jndi
    String accessMethod2 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[3]/td"));
    String sample2 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[3]/td[3]/a"));
    WebElement element2 = this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[3]/td[4]/img[@src='resources/ok.png']"));
    //sql.stringarray.jndi
    String accessMethod3 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[4]/td"));
    String sample3 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[4]/td[3]/a"));
    WebElement element3 = this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[4]/td[4]/img[@src='resources/ok.png']"));
    //mondrian.jdbc
    String accessMethod4 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[5]/td"));
    String sample4 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[5]/td[3]/a"));
    WebElement element4 = this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[5]/td[4]/img[@src='resources/ok.png']"));
    //mondrian.jndi
    String accessMethod5 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[6]/td"));
    String sample5 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[6]/td[3]/a"));
    WebElement element5 = this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[6]/td[4]/img[@src='resources/ok.png']"));
    // mondrian.jdbc (denormalized)
    String accessMethod6 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[7]/td"));
    String sample6 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[7]/td[3]/a"));
    WebElement element6 = this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[7]/td[4]/img[@src='resources/ok.png']"));
    //mondrian.jndi (denormalized)
    String accessMethod7 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[8]/td"));
    String sample7 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[8]/td[3]/a"));
    WebElement element7 = this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[8]/td[4]/img[@src='resources/ok.png']"));
    //olap4j
    String accessMethod8 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[9]/td"));
    String sample8 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[9]/td[3]/a"));
    WebElement element8 = this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[9]/td[4]/img[@src='resources/ok.png']"));
    //kettle
    String accessMethod9 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[10]/td"));
    String sample9 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[10]/td[3]/a"));
    WebElement element9 = this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[10]/td[4]/img[@src='resources/ok.png']"));
    //metadata
    String accessMethod10 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[11]/td"));
    String sample10 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[11]/td[3]/a"));
    WebElement element10 = this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[11]/td[4]/img[@src='resources/ok.png']"));
    //scripting
    String accessMethod11 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[12]/td"));
    String sample11 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[12]/td[3]/a"));
    WebElement element11 = this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[12]/td[4]/img[@src='resources/ok.png']"));
    //scripting (json object)
    String accessMethod12 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[13]/td"));
    String sample12 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[13]/td[3]/a"));
    WebElement element12 = this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[13]/td[4]/img[@src='resources/ok.png']"));
    //Xpath
    String accessMethod13 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[14]/td"));
    String sample13 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[14]/td[3]/a"));
    WebElement element13 = this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[14]/td[4]/img[@src='resources/ok.png']"));
    //Compound join
    String accessMethod14 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[15]/td"));
    String sample14 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[15]/td[3]/a"));
    WebElement element14 = this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[15]/td[4]/img[@src='resources/ok.png']"));
    //Compound Union
    String accessMethod15 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[16]/td"));
    String sample15 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[16]/td[3]/a"));
    WebElement element15 = this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//table[@id='testTable']/tbody/tr[16]/td[4]/img[@src='resources/ok.png']"));

    assertEquals("sql.jdbc", accessMethod1);
    assertEquals("cdafiles/sql-jdbc.cda", sample1);
    assertNotNull(element1);
    assertEquals("sql.jndi", accessMethod2);
    assertEquals("cdafiles/sql-jndi.cda", sample2);
    assertNotNull(element2);
    assertEquals("sql.stringarray.jndi", accessMethod3);
    assertEquals("cdafiles/sql-stringArray-jndi.cda", sample3);
    assertNotNull(element3);
    assertEquals("mondrian.jdbc", accessMethod4);
    assertEquals("cdafiles/mondrian-jdbc.cda", sample4);
    assertNotNull(element4);
    assertEquals("mondrian.jndi", accessMethod5);
    assertEquals("cdafiles/mondrian-jndi.cda", sample5);
    assertNotNull(element5);
    assertEquals("mondrian.jdbc (denormalized)", accessMethod6);
    assertEquals("cdafiles/denormalized-mondrian-jdbc.cda", sample6);
    assertNotNull(element6);
    assertEquals("mondrian.jndi (denormalized)", accessMethod7);
    assertEquals("cdafiles/denormalized-mondrian-jndi.cda", sample7);
    assertNotNull(element7);
    assertEquals("olap4j", accessMethod8);
    assertEquals("cdafiles/olap4j.cda", sample8);
    assertNotNull(element8);
    assertEquals("kettle", accessMethod9);
    assertEquals("cdafiles/kettle.cda", sample9);
    assertNotNull(element9);
    assertEquals("metadata", accessMethod10);
    assertEquals("cdafiles/metadata.cda", sample10);
    assertNotNull(element10);
    assertEquals("scripting", accessMethod11);
    assertEquals("cdafiles/scripting.cda", sample11);
    assertNotNull(element11);
    assertEquals("scripting (json object)", accessMethod12);
    assertEquals("cdafiles/json-scripting.cda", sample12);
    assertNotNull(element12);
    assertEquals("xpath", accessMethod13);
    assertEquals("cdafiles/xpath.cda", sample13);
    assertNotNull(element13);
    assertEquals("Compound join", accessMethod14);
    assertEquals("cdafiles/compoundJoin.cda", sample14);
    assertNotNull(element14);
    assertEquals("Compound Union", accessMethod15);
    assertEquals("cdafiles/compoundUnion.cda", sample15);
    assertNotNull(element15);
}

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

License:Apache License

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name://from  w  w w .ja v a 2 s . com
 *    Page Content
 * Description:
 *    The test case pretends to validate if the field filename and about
 *    are present and the about works as expected.
 * Steps:
 *    1. Check if we are reading the correct file
 *    2. Check if About is working
 */
@Test
public void tc1_PageContent_DisplayeFilenameAndAbout() {
    this.log.info("tc1_PageContent_DisplayeFilenameAndAbout");

    /*
     * ## Step 1
     */
    //Check if the field 'filename' exist and expected value

    String filename = this.elemHelper.WaitForTextPresence(driver, By.id("fileid"),
            "/public/plugin-samples/cda/cdafiles/mondrian-jndi.cda");
    String pleaseSelect = this.elemHelper.WaitForTextPresence(driver, By.id("pleaseselect"),
            "Please select a Data Access ID");

    assertEquals("/public/plugin-samples/cda/cdafiles/mondrian-jndi.cda", filename);
    assertEquals("Please select a Data Access ID", pleaseSelect);

    /*
     * ## Step 2
     */
    //Check the About
    this.elemHelper.FindElement(driver, By.linkText("About")).click();
    //element 'fileid'
    this.elemHelper.WaitForElementPresenceAndVisible(driver, By.id("fileid"));
    String textElementFileid = this.elemHelper.WaitForElementPresentGetText(driver, By.id("fileid"));
    //element image
    WebElement elemImg = this.elemHelper.FindElement(driver, By.cssSelector("img"));
    String imgAttrSrc = elemImg.getAttribute("src");
    //element //div[@id='aboutSubContainerLeft']/div[2]/p
    String textFirstParagExpected = "CDA is a Pentaho plugin designed for accessing data with great flexibility. Born to overcoming some cons of the older implementation, CDA allows you to access any of the various Pentaho data sources and:";
    String textFirstParag = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='aboutSubContainerLeft']/div[2]/p"));
    //element //div[@id='aboutSubContainerLeft']/div[2]/p[2]
    String textSecondParagExpected = "CDA can be used as a standalone plugin on the Pentaho BI server or in combination with CDE / CDF.";
    String textSecondParag = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='aboutSubContainerLeft']/div[2]/p[2]"));

    assertEquals("Hello!", textElementFileid);
    assertEquals(baseUrl + "api/repos/cda/static/img/cda.png", imgAttrSrc);
    assertEquals(textFirstParagExpected, textFirstParag);
    assertEquals(textSecondParagExpected, textSecondParag);

    //Back to Mondrian JNDI
    this.elemHelper.Click(driver, By.linkText("Back to CDA"));
    //Check if we are in the correct page
    filename = this.elemHelper.WaitForTextPresence(driver, By.id("fileid"),
            "/public/plugin-samples/cda/cdafiles/mondrian-jndi.cda");
    pleaseSelect = this.elemHelper.WaitForTextPresence(driver, By.id("pleaseselect"),
            "Please select a Data Access ID");

    assertEquals("/public/plugin-samples/cda/cdafiles/mondrian-jndi.cda", filename);
    assertEquals("Please select a Data Access ID", pleaseSelect);
    assertNotNull(this.elemHelper.FindElement(driver, By.linkText("About")));
}

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

License:Apache License

/**
 * ############################### Test Case 4 ###############################
 *
 * Test Case Name:/*from  w ww  .j ava  2  s  .c  o m*/
 *    Query URL
 * Description:
 *    The test case pretends to validate return data when call query url.
 * Steps:
 *    1. Check query url diaLOG
 *    2. Open a new browser with query url
 */
@Test
public void tc4_QueryURL_ReturnValueIsTheSameDisplayedInPage() {
    this.log.info("tc4_QueryURL_ReturnValueIsTheSameDisplayedInPage");

    /*
     * ## Step 1
     */
    //Check we have three elements and no more than that
    String textPaging = this.elemHelper.WaitForElementPresentGetText(driver, By.id("contents_info"));
    assertEquals(textPaging, "View 1 to 3 of 3 elements");

    // Check query url
    WebElement buttonQueryUrl = this.elemHelper.WaitForElementPresence(driver, By.id("queryUrl"));
    assertEquals(buttonQueryUrl.getText(), "Query URL");
    this.elemHelper.ClickJS(driver, By.id("queryUrl"));

    this.elemHelper.WaitForElementPresenceAndVisible(driver, By.id("queryUrlDialog"));
    String diaLOGTitle = this.elemHelper.WaitForElementPresentGetText(driver,
            By.cssSelector("div#queryUrlDialog p.dialogTitle"));
    assertEquals(diaLOGTitle, "Query Execution URL:");

    WebElement inputQueryUrl = this.elemHelper.FindElement(driver, By.id("doQueryUrl"));
    String queryUrl = inputQueryUrl.getAttribute("value");
    this.log.debug("Query URL: " + queryUrl);

    this.elemHelper.ClickJS(driver, By.linkText("Close"));

    /*
     * ## Step 2
     */
    driver.get(queryUrl);
    String jsonQueryActual = this.elemHelper.WaitForTextDifferentEmpty(driver, By.cssSelector("body"));
    String jsonQueryExpected = "{\"queryInfo\":{\"totalRows\":\"3\"},\"resultset\":[[\"All Years\",\"2003\",3573701.2500000023,3.5737012500000023],[\"All Years\",\"2004\",4750205.889999998,4.750205889999998],[\"All Years\",\"2005\",1513074.4600000002,1.5130744600000002]],\"metadata\":[{\"colIndex\":0,\"colType\":\"String\",\"colName\":\"[Time].[(All)]\"},{\"colIndex\":1,\"colType\":\"String\",\"colName\":\"Year\"},{\"colIndex\":2,\"colType\":\"Numeric\",\"colName\":\"price\"},{\"colIndex\":3,\"colType\":\"Numeric\",\"colName\":\"PriceInK\"}]}";
    JsonParser parser = new JsonParser();
    JsonElement actual = parser.parse(jsonQueryActual);
    JsonElement expected = parser.parse(jsonQueryExpected);
    assertEquals(actual, expected);

    driver.get(PageUrl.MONDRIAN_JNDI);
    String filename = this.elemHelper.WaitForTextPresence(driver, By.id("fileid"),
            "/public/plugin-samples/cda/cdafiles/mondrian-jndi.cda");
    String pleaseSelect = this.elemHelper.WaitForTextPresence(driver, By.id("pleaseselect"),
            "Please select a Data Access ID");
    assertEquals("/public/plugin-samples/cda/cdafiles/mondrian-jndi.cda", filename);
    assertEquals("Please select a Data Access ID", pleaseSelect);
}

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

License:Apache License

/**
 * ############################### Test Case 4 ###############################
 *
 * Test Case Name://from ww w  .  ja v  a 2 s. c o  m
 *    Query URL
 * Description:
 *    The test case pretends to validate return data when call query url.
 * Steps:
 *    1. Select the option 'Mdx...'
 *    2. Click in Cache this
 *    3. Set a period
 *    4. In the new window, check the schedule
 *    5. Remove the schedule
 */
@Test
public void tc5_CacheThisSimple_ScheduleIsSetSuccessful() {
    this.log.info("tc5_CacheThisSimple_ScheduleIsSetSuccessful");
    String selectedHours = "21";

    /*
     * ## Step 1
     */
    Select select = new Select(this.elemHelper.FindElement(driver, By.id("dataAccessSelector")));
    select.selectByVisibleText("Mdx Query on SampleData - Jndi");
    //wait to render page
    this.elemHelper.WaitForElementInvisibility(driver, By.cssSelector("div.blockUI.blockOverlay"));
    //Check the presented contains
    WebElement elemStatus = this.elemHelper.FindElement(driver, By.id("status"));
    assertEquals("Shipped", elemStatus.getAttribute("value"));
    //Check we have three elements and no more than that
    String textPaging = this.elemHelper.WaitForElementPresentGetText(driver, By.id("contents_info"));
    assertEquals("View 1 to 3 of 3 elements", textPaging);

    /*
     * ## Step 2
     */
    //Click in 'Cache this'
    this.elemHelper.ClickJS(driver, By.id("cachethis"));
    this.elemHelper.WaitForElementPresenceAndVisible(driver, By.id("dialog"));
    String questionActual = this.elemHelper.WaitForElementPresentGetText(driver,
            By.cssSelector("p.dialogTitle"));
    String questionExpect = "What schedule should this query run on? (advanced)";
    assertEquals(questionExpect, questionActual);

    /*
     * ## Step 3
     */
    String parentWindowHandle = driver.getWindowHandle();
    Select selectPeriod = new Select(this.elemHelper.FindElement(driver, By.id("periodType")));
    selectPeriod.selectByValue("1"); //every day

    this.elemHelper.FindElement(driver, By.xpath("//input[@id='startAt']")).clear();
    this.elemHelper.FindElement(driver, By.xpath("//input[@id='startAt']")).sendKeys(selectedHours);
    this.elemHelper.FindElement(driver, By.linkText("Ok")).click();

    Set<String> listWindows = driver.getWindowHandles();
    //wait for popup render
    this.elemHelper.WaitForNewWindow(driver);
    listWindows = driver.getWindowHandles();
    //Get popup id
    WebDriver cdaCacheManager = null;
    Iterator<String> iterWindows = listWindows.iterator();
    while (iterWindows.hasNext()) {
        String windowHandle = iterWindows.next();
        cdaCacheManager = driver.switchTo().window(windowHandle);
        if (cdaCacheManager.getTitle().equals("CDA Cache Manager")) {
            break;
        }
    }
    //Validate page:
    //Title
    String titleCdaCacheManager = cdaCacheManager.getTitle();
    assertEquals("CDA Cache Manager", titleCdaCacheManager);
    //Scheduled queries
    String subTitleText = this.elemHelper.WaitForElementPresentGetText(cdaCacheManager,
            By.xpath("//div[@id='scheduledQueries']/div"));
    assertEquals("Scheduled Queries", subTitleText);

    /*
     * ## Step 4
     */
    //Validate Query
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String strToday = sdf.format(new Date());
    String queryName = this.elemHelper.WaitForElementPresentGetText(cdaCacheManager,
            By.xpath("//div[@id='lines']/div/div[1]"));
    String queryParam1 = this.elemHelper.WaitForElementPresentGetText(cdaCacheManager,
            By.xpath("//div[@id='lines']/div/div[2]//dl//dt"));
    String queryParam2 = this.elemHelper.WaitForElementPresentGetText(cdaCacheManager,
            By.xpath("//div[@id='lines']/div/div[2]//dl//dd"));
    String queryLExec = this.elemHelper.WaitForElementPresentGetText(cdaCacheManager,
            By.xpath("//div[@id='lines']/div/div[3]"));
    String queryNExec = this.elemHelper.WaitForElementPresentGetText(cdaCacheManager,
            By.xpath("//div[@id='lines']/div/div[4]"));
    String queryCron = this.elemHelper.WaitForElementPresentGetText(cdaCacheManager,
            By.xpath("//div[@id='lines']/div/div[5]"));
    String queryTime = this.elemHelper.WaitForElementPresentGetText(cdaCacheManager,
            By.xpath("//div[@id='lines']/div/div[6]"));
    String queryStatus = this.elemHelper.WaitForElementPresentGetText(cdaCacheManager,
            By.xpath("//div[@id='lines']/div/div[7]"));

    //AssertPopup for execute and delete
    WebElement delete = this.elemHelper.FindElement(cdaCacheManager,
            By.xpath("//a/img[@title='Remove Query']"));
    WebElement execute = this.elemHelper.FindElement(cdaCacheManager,
            By.xpath("//a/img[@title='Execute Query']"));
    assertNotNull(execute);
    assertNotNull(delete);

    //Validate execution details
    try {
        assertEquals("/public/plugin-samples/cda/cdafiles/mondrian-jndi.cda (1)", queryName);
        assertEquals("status", queryParam1);
        assertEquals("Shipped", queryParam2);
        assertThat("Last Execution: " + queryLExec, queryLExec, CoreMatchers.containsString("1970-01-01"));
        assertThat("Last Execution: " + queryLExec, queryLExec, CoreMatchers.containsString("00:00:00"));
        assertThat("Next Execution: " + queryNExec, queryNExec, CoreMatchers.containsString(strToday));
        assertThat("Next Execution: " + queryNExec, queryNExec,
                CoreMatchers.containsString(selectedHours + ":00:00"));
        assertEquals("0 0 21 * * ? *", queryCron);
        assertEquals("-1", queryTime);
        assertEquals("Success", queryStatus);
    } catch (AssertionError ae) {
        this.log.error(ae.getMessage());

        //Remove schedule
        this.removeFirstSchedule();

        //Need guarantee we close everything
        cdaCacheManager.close();
        driver.switchTo().window(parentWindowHandle);

        //raise the exception
        fail(ae.getMessage());
    }

    /*
     * ## Step 5
     */
    this.removeFirstSchedule();

    cdaCacheManager.close();
    driver.switchTo().window(parentWindowHandle);
    assertTrue(driver.getWindowHandles().size() == 1);
}

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

License:Apache License

/**
 * ############################### Test Case 2 ###############################
 *
 * Test Case Name:/*from   w  w w . java  2  s  . c o m*/
 *    Sparkline
 * Description:
 *    The test case pretends to validate the sparkline sample.
 * Steps:
 *    1. Check if the sample for 'sparkline' has its contents present
 *    2. Order the table
 */
@Test
public void tc02_Sparkline_SampleWorks() {
    this.log.info("tc02_Sparkline_SampleWorks");

    /*
     * ## Step 1
     */
    String sampleTitle = this.elemHelper.WaitForElementPresentGetText(driver, By.id("SparklineTitle"));
    assertEquals("sparkline", sampleTitle);
    //Check the hyperlink
    WebElement elemUrl = this.elemHelper.FindElement(driver, By.linkText("JQuery Sparkline plugin"));
    String attrHref = elemUrl.getAttribute("href");
    assertEquals("http://www.omnipotent.net/jquery.sparkline/", attrHref);

    //Check Defaults
    String defaultText = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//div[@id='SparklineDescHtml']/blockquote/pre"));
    assertEquals("defaults: { type: 'line' }", defaultText);

    //Check Rows
    String row1 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='SparklineObjTable']/tbody/tr/td"));
    String row2 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='SparklineObjTable']/tbody/tr[2]/td"));
    assertEquals("Row 1", row1);
    assertEquals("Row 2", row2);

    //Check column Default Sparklin
    WebElement chartRow1Col1 = this.elemHelper.FindElement(driver,
            By.xpath("//table[@id='SparklineObjTable']/tbody/tr[1]/td[2]/canvas"));
    WebElement chartRow1Col2 = this.elemHelper.FindElement(driver,
            By.xpath("//table[@id='SparklineObjTable']/tbody/tr[1]/td[3]/canvas"));
    WebElement chartRow2Col1 = this.elemHelper.FindElement(driver,
            By.xpath("//table[@id='SparklineObjTable']/tbody/tr[2]/td[2]/canvas"));
    WebElement chartRow2Col2 = this.elemHelper.FindElement(driver,
            By.xpath("//table[@id='SparklineObjTable']/tbody/tr[2]/td[3]/canvas"));
    assertNotNull(chartRow1Col1);
    assertNotNull(chartRow1Col2);
    assertNotNull(chartRow2Col1);
    assertNotNull(chartRow2Col2);

    /*
     * ## Step 3
     */
    //Check ordering
    this.elemHelper.ClickJS(driver, By.xpath("//table[@id='SparklineObjTable']/thead/tr/th[1]"));
    this.elemHelper.ClickJS(driver, By.xpath("//table[@id='SparklineObjTable']/thead/tr/th[1]"));
    this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.xpath("//table[@id='SparklineObjTable']/thead/tr/th[1][@class='column0 string sorting_desc']"));
    row1 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='SparklineObjTable']/tbody/tr/td"));
    row2 = this.elemHelper.WaitForElementPresentGetText(driver,
            By.xpath("//table[@id='SparklineObjTable']/tbody/tr[2]/td"));
    assertEquals("Row 2", row1);
    assertEquals("Row 1", row2);
}

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

License:Apache License

/**
 *
 * @param value// ww  w .j av a 2s . co  m
 */
private void ChangeFontSize(String value) {
    this.log.info("ChangeFontSize");
    driver.get(PageUrl.ADDIN_REFERENCE_EDIT);

    //Expand first row - Title
    this.elemHelper.ClickJS(driver, By.xpath("//table[@id='table-cdfdd-layout-tree']/tbody/tr[5]/td/span"));
    //Click in HTML to open the Properties
    Actions acts = new Actions(driver);
    acts.click(this.elemHelper.FindElement(driver,
            By.xpath("//table[@id='table-cdfdd-layout-tree']/tbody/tr[6]/td[1]")));
    acts.build().perform();
    //Click in field 'Font Size' to be editable
    this.elemHelper.ClickJS(driver, By.xpath("//table[@id='table-cdfdd-layout-properties']/tbody/tr[3]/td[2]"));
    //Write 34
    this.elemHelper.FindElement(driver, By.name("value")).clear();
    this.elemHelper.SendKeys(driver, By.name("value"), value);
    this.elemHelper.FindElement(driver, By.name("value")).submit();
    this.bFontChanged = true;
    //Save the changes
    this.elemHelper.ClickJS(driver, By.linkText("Save"));
    //Wait for element present and invisible
    this.elemHelper.WaitForElementVisibility(driver, By.xpath("//div[@id='notifyBar']"));
    this.elemHelper.WaitForElementInvisibility(driver, By.xpath("//div[@id='notifyBar']"));
}

From source file:com.pentaho.ctools.cde.require.AddinReferenceEdit.java

License:Apache License

/**
 *
 * @param value//from w w  w .  j av  a  2 s. c  om
 */
private void ChangeFontSize(String value) {
    this.log.info("ChangeFontSize");
    driver.get(PageUrl.ADDIN_REFERENCE_REQUIRE_EDIT);

    //Expand first row - Title
    this.elemHelper.ClickJS(driver, By.xpath("//table[@id='table-cdfdd-layout-tree']/tbody/tr[5]/td/span"));
    //Click in HTML to open the Properties
    Actions acts = new Actions(driver);
    acts.click(this.elemHelper.FindElement(driver,
            By.xpath("//table[@id='table-cdfdd-layout-tree']/tbody/tr[6]/td[1]")));
    acts.build().perform();
    //Click in field 'Font Size' to be editable
    this.elemHelper.ClickJS(driver, By.xpath("//table[@id='table-cdfdd-layout-properties']/tbody/tr[3]/td[2]"));
    //Write 34
    this.elemHelper.FindElement(driver, By.name("value")).clear();
    this.elemHelper.SendKeys(driver, By.name("value"), value);
    this.elemHelper.FindElement(driver, By.name("value")).submit();
    this.bFontChanged = true;
    //Save the changes
    this.elemHelper.ClickJS(driver, By.linkText("Save"));
    //Wait for element present and invisible
    this.elemHelper.WaitForElementVisibility(driver, By.xpath("//div[@id='notifyBar']"));
    this.elemHelper.WaitForElementInvisibility(driver, By.xpath("//div[@id='notifyBar']"));
}

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

License:Apache License

/**
 * ############################### Test Case 3 ###############################
 *
 * Test Case Name://from ww w  .j a  va  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() {
    /*
     * ## 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);

    wait.until(ExpectedConditions.alertIsPresent());
    Alert alert = driver.switchTo().alert();
    String confirmationMsg = alert.getText();
    String expectedCnfText = "You chose from " + strToday + " to " + strToday;
    alert.accept();

    assertEquals(confirmationMsg, expectedCnfText);
}

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

License:Apache License

/**
 * ############################### Test Case 4 ###############################
 *
 * Test Case Name:/* ww  w  .ja  va  2 s  .  com*/
 *    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() {
    /*
     * ## 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);

    wait.until(ExpectedConditions.alertIsPresent());
    Alert alert = driver.switchTo().alert();
    String confirmationMsg = alert.getText();
    String expectedCnfText = "You chose from " + sdf.format(c.getTime()) + " to " + strToday;
    alert.accept();

    assertEquals(confirmationMsg, expectedCnfText);
}