1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
package com.vaadin.tests.elements.treetable;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.TreeTableElement;
import com.vaadin.testbench.elements.TreeTableRowElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class TreeTableElementExpandRowTest extends MultiBrowserTest {
TreeTableElement tree;
@Before
public void init() {
openTestURL();
tree = $(TreeTableElement.class).first();
}
@Test
public void testGetRow() {
testRowByIndex(1, "testValue", "");
}
@Test
public void testExpandRow0() {
TreeTableRowElement row = tree.getRow(0);
row.toggleExpanded();// expand row
testRowByIndex(1, "item1_1", "Should expand row with index 0.");
testRowByIndex(2, "item1_2", "Should expand row with index 0.");
}
@Test
public void testCollapseRow0() {
TreeTableRowElement row = tree.getRow(0);
row.toggleExpanded();// expand row
testRowByIndex(1, "item1_1", "Should expand row with index 0.");
row = tree.getRow(0);
row.toggleExpanded(); // collapse row
testRowByIndex(1, "testValue", "Should collapse row with index 0.");
}
private void testRowByIndex(int rowIndex, String expectedValue,
String extraInfo) {
TreeTableRowElement row = tree.getRow(rowIndex);
WebElement cell = row.getCell(0);
String errorMessage = "";
if (extraInfo != null && !extraInfo.isEmpty()) {
errorMessage += extraInfo;
}
errorMessage += "Return value of row=" + rowIndex + " cell=0 should be "
+ expectedValue + ".";
assertEquals(errorMessage, expectedValue, cell.getText());
}
}
|