Package com.meterware.httpunit

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


    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

    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

                                                     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

    }

    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

    // 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

   
    // 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

      // Start the conversation
    WebResponse resp = Util.navToItem("EST-4");
   
    // Check the first two rows of the table
    WebTable itemTable = resp.getTableStartingWith("EST-4");
    itemTable.purgeEmptyCells();
    String[][] table = itemTable.asText();
    assertEquals( "EST-4",  table[0][0].trim() );
    assertTrue( table[1][0].contains("9999 in Stock") );
   }
View Full Code Here

    // 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());
    assertEquals( "FI-FW-01", table[1][1].trim());
    assertTrue( table[1][2].contains("Spotted") );
    assertEquals( "$18.50",  table[1][6].trim() );
   }
View Full Code Here

    // 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());
   
    // Now remove it
    resp = resp.getLinkWith(Util.getBundle("view", "buttonRemove")).click(); // "Remove"
   
View Full Code Here

TOP

Related Classes of com.meterware.httpunit.WebTable

Copyright © 2018 www.massapicom. 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.