Webiyo

This page was generated using Webiyo. See its source code and unit tests.

org/webiyo/util/test/RowChecker.java

package org.webiyo.util.test;

import junit.framework.Assert;
import org.w3c.dom.Element;
import org.webiyo.xml.XmlException;

public class RowChecker extends ElementChecker {

    public RowChecker(Element element, String elementXPath) {
        super(element, elementXPath);
        Assert.assertEquals("tr", element.getNodeName());
    }

    public void checkCells(String... expectedCellText) throws XmlException {
        for (int i = 0; i < expectedCellText.length; i++) {
            Assert.assertEquals("cell " + (i + 1) + "of " + currentXPath + " contains unexpected text",
                                expectedCellText[i],
                                cell(i).element.getTextContent());
        }

        Assert.assertEquals("wrong number of <td> elements in " + currentXPath, expectedCellText.length, cellCount());
    }

    public int cellCount() throws XmlException {
        return select("td").size();
    }

    public ElementChecker cell(int i) throws XmlException {
        return navigateTo("td[" + (i + 1) + "]");
    }
}
SourceForge