Examples of WebTable


Examples of com.meterware.httpunit.WebTable

            Assert.assertEquals(
                "Content in cell [" + j + ",2] in main table is wrong",
                KnownValue.BEE,
                tables[0].getCellAsText(j, 2));

            WebTable nested = tables[0].getTableCell(j, 3).getFirstMatchingTable(new HTMLElementPredicate()
            {

                @Override
                public boolean matchesCriteria(Object htmlElement, Object criteria)
                {
                    return true;
                }
            }, null);

            Assert.assertNotNull("Nested table not found in cell [" + j + ",3]", nested);
            Assert.assertEquals("Wrong number of columns in nested table", 3, nested.getColumnCount());
            Assert.assertEquals("Wrong number of rows in nested table", 4, nested.getRowCount());

            for (int x = 1; x < nested.getRowCount(); x++)
            {
                Assert.assertEquals(
                    "Content in cell [" + x + ",0] in nested table is wrong",
                    Integer.toString(x),
                    nested.getCellAsText(x, 0));
                Assert.assertEquals(
                    "Content in cell [" + x + ",1] in nested table is wrong",
                    KnownValue.ANT,
                    nested.getCellAsText(x, 1));
                Assert.assertEquals(
                    "Content in cell [" + x + ",2] in nested table is wrong",
                    KnownValue.CAMEL,
                    nested.getCellAsText(x, 2));
            }

        }

    }
View Full Code Here

Examples of com.meterware.httpunit.WebTable

        assertEquals("on", form.getParameterValue("searchForm:searchTags"));
        String searchText = "cat";
        form.setParameter("searchForm:searchString", searchText);
        form.submit();
        resp = wc.getCurrentPage();
        WebTable resultTable = resp.getTableStartingWithPrefix("Map");
        assertTrue(resultTable.getRowCount() > 2);
    }
View Full Code Here

Examples of com.meterware.httpunit.WebTable

        tester.setFormElement("startTime[" + slot + "]", startTime);
        tester.selectOption("person1Id[" + slot + "]", firstPersonInitials);
        tester.submit();
        tester.assertOnTaskPage();
        tester.assertTextInTable("time_entries", startTime);
        WebTable table = tester.getDialog().getWebTableBySummaryOrId("time_entries");
        assertTrue("endTime not empty", StringUtils.isBlank(table.getCellAsText(1, 1)));
        assertTrue("duration not empty", StringUtils.isBlank(table.getCellAsText(1, 3)));
    }
View Full Code Here

Examples of com.meterware.httpunit.WebTable

        tester.login(person.getUserId(), "test");

        tester.assertKeyPresent("projects.title");

        // Custom table assert - may be other projects here
        WebTable table = tester.getDialog().getWebTableBySummaryOrId("objecttable");
        boolean foundProject = false;
        boolean foundHiddenProject = false;
        int nrow = table.getRowCount();
        for (int r = 0; r < nrow; r++) {
            if (table.getCellAsText(r, 0).trim().equals(project.getName())) {
                foundProject = true;
                assertEquals("N",table.getCellAsText(r, 2).trim());
                assertImageInCell(table, r, 3, EDIT_IMAGE);
                assertImageInCell(table, r, 3, DELETE_IMAGE);
            } else if (table.getCellAsText(r, 0).trim().equals(hiddenProject.getName())) {
                foundHiddenProject = true;
                assertEquals("Y", table.getCellAsText(r, 2).trim());
                assertImageInCell(table, r, 3, EDIT_IMAGE);
                assertImageInCell(table, r, 3, DELETE_IMAGE);
            }
        }
        assertTrue("missing row", foundProject);
View Full Code Here

Examples of com.meterware.httpunit.WebTable

    public void clickEditTimeImage() {
        assertOnTaskPage();
        HttpUnitDialog dialog = getDialog();
        WebResponse taskPage = dialog.getResponse();
        WebTable timeTable;
        try {
            timeTable = taskPage.getTableWithID("time_entries");
            int lastRowIndex = timeTable.getRowCount() - 1;
            TableCell lastRowCell = timeTable.getTableCell(lastRowIndex, 0);
            HTMLElementPredicate imagePredicate = new LinkImagePredicate();
            WebLink editLink = lastRowCell.getFirstMatchingLink(imagePredicate, EDIT_IMAGE);
            editLink.click();
        } catch (Exception e) {
            throw new RuntimeException(ExceptionUtility.stackTraceToString(e));
View Full Code Here

Examples of com.meterware.httpunit.WebTable

    public void clickImageLinkInNoteWithSubject(String imageName, String subject) {
        int linkRowInNoteTable = 2;
        HttpUnitDialog dialog = getDialog();
        WebResponse storyPage = dialog.getResponse();
        try {
            WebTable noteTable = storyPage.getFirstMatchingTable(new TextInTablePredicate(), subject);
            TableCell linkCell = noteTable.getTableCell(linkRowInNoteTable, 0);
            WebLink deleteLink = linkCell.getFirstMatchingLink(new LinkImagePredicate(), imageName);
            clickLink(deleteLink);
        } catch (Exception e) {
            throw new RuntimeException(ExceptionUtility.stackTraceToString(e));
        }
View Full Code Here

Examples of com.meterware.httpunit.WebTable

                                                     String text) {
        boolean foundLink = false;
        HttpUnitDialog dialog = getDialog();
        WebResponse editPage = dialog.getResponse();
        try {
            WebTable objectTable = editPage.getTableWithID(tableId);
            if (objectTable == null)
                throw new RuntimeException("Acceptance tests require table with id = " + tableId);
            int rowToSearchForLink = getFirstRowNumberWithText(objectTable, text);
            for (int column = 0; column < objectTable.getColumnCount(); column++) {
                TableCell cell = objectTable.getTableCell(rowToSearchForLink, column);
                LinkImagePredicate predicate = new LinkImagePredicate();
                WebLink editLink = cell.getFirstMatchingLink(predicate, imageName);
                if (editLink != null) {
clickLink(                    editLink);
                    foundLink = true;
View Full Code Here

Examples of com.meterware.httpunit.WebTable

    }

    public static class TextInTablePredicate implements HTMLElementPredicate {

       public boolean matchesCriteria(Object object, Object criteria) {
           WebTable table = (WebTable) object;
           String textToMatch = (String) criteria;
           for (int i = 0; i < table.getRowCount(); i++)
               for (int j = 0; j < table.getColumnCount(); j++) {
                   TableCell cell = table.getTableCell(i, j);
                   if (cell != null && cell.asText().indexOf(textToMatch) != -1)
                       return true;
               }

           return false;
View Full Code Here

Examples of com.meterware.httpunit.WebTable

    // Add the item to the cart
    resp = resp.getLinkWith(Util.getBundle("view", "buttonAddToCart")).click();

    // Make sure item is in the cart
    // Check the first two rows of the table
    WebTable itemTable = resp.getTableStartingWith(Util.getBundle("view", "itemIdLabel")); // "Item ID"
    itemTable.purgeEmptyCells();
    String[][] table = itemTable.asText();
    assertEquals( "EST-4", table[1][0].trim());
   
      // proceed to checkout
    resp = resp.getLinkWith(Util.getBundle("view", "buttonProceedToCheckout")).click(); // "Proceed to Checkout"
   
    // Make sure it says Checkout Summary
    assertTrue(resp.getText().contains(Util.getBundle("view", "checkoutSummaryLabel"))); // "Checkout Summary"
   
    // Now click continue
    resp = resp.getLinkWith(Util.getBundle("view", "buttonContinue")).click(); // "Continue >>"
   
    // Sign in
    WebForm form = resp.getForms()[1];
    form.setParameter( "j_username", "beehive" );
    form.setParameter( "j_password", "beehive" );
    resp = form.submit();   
   
    // Enter the Checkout Info
    form = resp.getForms()[1];
    form.setParameter( "wlw-select_key:{actionForm.order.cardType}", "American Express" );
    form.setParameter( "{actionForm.order.creditCard}", "1234" );
    form.setParameter( "{actionForm.order.exprDate}", "09-2000" );
    form.setParameter( "wlw-radio_button_group_key:{actionForm.order.billingAddress}", "1" );
    form.setParameter( "wlw-radio_button_group_key:{actionForm.order.shippingAddress}", "1" );
    resp = form.submit();
   
    // Make sure it took
    assertTrue(resp.getText().contains(Util.getBundle("view", "confirmMessage"))); // "Please confirm the information below and then press continue..."
    itemTable = resp.getTableWithID("orderTable");
    itemTable.purgeEmptyCells();
    table = itemTable.asText();
    assertEquals( "American Express", table[1][1].trim());
    assertEquals( "1234", table[2][1].trim());
    assertEquals( "09-2000", table[3][1].trim());
   
    // Click Continue
View Full Code Here

Examples of com.meterware.httpunit.WebTable

   
    // go to orders
    resp = resp.getLinkWith(Util.getBundle("account", "listOrdersLabel")).click(); // "List Orders"
   
    // Make sure the new order appears with the proper total price
    WebTable itemTable = resp.getTableStartingWith(Util.getBundle("view", "orderId")); // "Order ID"
    String[][] table = itemTable.asText();
    assertEquals( "1", table[1][0].trim());
    assertEquals( "$18.50",  table[1][2].trim() );   
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.