blob: 43ffca87d543d80325b06364be3d32046892564b (
plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
package com.vaadin.tests.elements.table;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.elements.TableElement;
import com.vaadin.testbench.elements.TableRowElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class TableGetRowTest extends MultiBrowserTest {
private static final String GET_ROW_ERROR_MESSAGE = "TableElement.getRow() returns wrong row.";
private static final String GET_CELL_ERROR_MESSAGE = "TableElement.getCell() returns wrong cell.";
@Override
protected Class<?> getUIClass() {
return TableScroll.class;
}
TableElement table;
int firstRow = 0;
int firstCol = 0;
@Before
public void init() {
openTestURL();
table = $(TableElement.class).first();
}
@Test
public void getTopRowTest() {
TableRowElement row = table.getRow(0);
WebElement cell = row.getCell(0);
String expected = "col=0 row=0";
String actual = cell.getText();
assertEquals(GET_ROW_ERROR_MESSAGE, expected, actual);
}
@Test
public void getFifthRowTest() {
TableRowElement row = table.getRow(4);
WebElement cell = row.getCell(1);
String expected = "col=1 row=4";
String actual = cell.getText();
assertEquals(GET_ROW_ERROR_MESSAGE, expected, actual);
}
@Test
public void rowGetCellTest() {
TestBenchElement cellFromTable = table.getCell(firstRow, firstCol);
WebElement cellFromRow = table.getRow(firstRow).getCell(firstCol);
assertEquals(
"Table.getCell() and Row.getCell() return different values",
cellFromRow.getText(), cellFromTable.getText());
}
@Test
public void tableGetCellTest() {
TestBenchElement cell = table.getCell(firstRow, firstCol);
String actual = cell.getText();
String expected = "col=0 row=0";
assertEquals(GET_CELL_ERROR_MESSAGE, expected, actual);
}
@Test(expected = NoSuchElementException.class)
public void getRowExceptionTest() {
table.getRow(-5);
}
@Test(expected = NoSuchElementException.class)
public void tableGetCellExceptionTest() {
table.getCell(-1, -1);
}
}
|