Selenium assertText for all text in a table?
I n开发者_如何学Goeed to assert that each row in table contains a certain text string, either through selenium IDE or a Java test case. What's the best way to do this? Here's my current test:
Command assertText
Target //table[@id='myTable']//tbody//tr[not(@style)]/td[1]
Value myValue
I need to test the first column of every row, but this only tests the first row. Is there an easy way to test every row?
I haven't used selenium IDE, only the java API, so here how I'd do it in java (or the basic idea at least)
int numRows = selenium.getXpathCount("table[@id='myTable']//tbody//" +
"tr[not(@style)]/td[1]").intValue();
String[] values = new String[numRows];
for (int i = 0; i < numRows; i++) {
values[i] = selenium.getText("table[@id='myTable']//tbody//" +
"tr[not(@style)][" + i + "]/td[1]");
}
精彩评论