Skip to content

Commit 43df12e

Browse files
committed
Rework relative locator tests, stabilize testByImageLocator
1 parent 1af9784 commit 43df12e

File tree

2 files changed

+132
-184
lines changed

2 files changed

+132
-184
lines changed

src/test/java/automationpractice/forms/ChallengingDomForm.java

Lines changed: 5 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -7,89 +7,17 @@
77
public class ChallengingDomForm extends Form {
88

99
public static final String LOCATOR_CHALLENGING_DOM_FORM = "//h3[contains(text(),'Challenging DOM')]";
10-
public static final String ELEMENT_NAME_ROW3_COLUMN5 = "Cell in row 3 column 5";
11-
public static final String ELEMENT_NAME_ROW5_COLUMN5 = "Cell in row 5 column 5";
12-
public static final String ELEMENT_NAME_ROW7_COLUMN5 = "Cell in row 7 column 5";
13-
public static final String ELEMENT_NAME_ROW5_COLUMN7 = "Cell in row 5 column 7";
14-
public static final String ELEMENT_NAME_ROW5_COLUMN3 = "Cell in row 5 column 3";
15-
public static final String ELEMENT_NAME_ROW1_COLUMN1 = "Cell in row 1 column 1";
16-
public static final String ELEMENT_NAME_ROW2_COLUMN1 = "Cell in row 2 column 1";
17-
public static final String ELEMENT_NAME_HEADER_CHALLENGING_DOM = "Header of Challenging Dom";
18-
19-
private final String locatorCellRow5Column5 = "//tr[5]/td[5]";
20-
private final String locatorCellRow3Column5 = "//tr[3]/td[5]";
21-
private final String locatorCellRow7Column5 = "//tr[7]/td[5]";
22-
private final String locatorCellRow5Column3 = "//tr[5]/td[3]";
23-
private final String locatorCellRow5Column7 = "//tr[5]/td[7]";
24-
private final String locatorCellRow1Column1 = "//tr[1]/td[1]";
25-
private final String locatorCellRow2Column1 = "//tr[2]/td[1]";
26-
27-
private ILabel headerName = getElementFactory().getLabel(By.xpath(LOCATOR_CHALLENGING_DOM_FORM), ELEMENT_NAME_HEADER_CHALLENGING_DOM);
28-
private ILabel cellInRow3Column5 = getElementFactory().getLabel(By.xpath(locatorCellRow3Column5), ELEMENT_NAME_ROW3_COLUMN5);
29-
private ILabel cellInRow5Column5 = getElementFactory().getLabel(By.xpath(locatorCellRow5Column5), ELEMENT_NAME_ROW5_COLUMN5);
30-
private ILabel cellInRow7Column5 = getElementFactory().getLabel(By.xpath(locatorCellRow7Column5), ELEMENT_NAME_ROW7_COLUMN5);
31-
private ILabel cellInRow5Column7 = getElementFactory().getLabel(By.xpath(locatorCellRow5Column7), ELEMENT_NAME_ROW5_COLUMN7);
32-
private ILabel cellInRow5Column3 = getElementFactory().getLabel(By.xpath(locatorCellRow5Column3), ELEMENT_NAME_ROW5_COLUMN3);
33-
private ILabel cellInRow1Column1 = getElementFactory().getLabel(By.xpath(locatorCellRow1Column1), ELEMENT_NAME_ROW1_COLUMN1);
34-
private ILabel cellInRow2Column1 = getElementFactory().getLabel(By.xpath(locatorCellRow2Column1), ELEMENT_NAME_ROW2_COLUMN1);
3510

3611
public ChallengingDomForm() {
37-
super(By.xpath(LOCATOR_CHALLENGING_DOM_FORM), "Challenging DOM");
38-
}
39-
40-
public ILabel getCellInRow3Column5() {
41-
return cellInRow3Column5;
12+
super(By.xpath(LOCATOR_CHALLENGING_DOM_FORM), "Header of Challenging Dom");
4213
}
4314

44-
public ILabel getCellInRow5Column5() {
45-
return cellInRow5Column5;
15+
public String getHeaderText() {
16+
return getFormLabel().getText();
4617
}
4718

48-
public ILabel getCellInRow7Column5() {
49-
return cellInRow7Column5;
19+
public ILabel getCell(int row, int column) {
20+
return getElementFactory().getLabel(By.xpath(String.format("//tr[%d]/td[%d]", row, column)), String.format("Cell at row %d and column %d", row, column));
5021
}
5122

52-
public ILabel getCellInRow5Column7() {
53-
return cellInRow5Column7;
54-
}
55-
56-
public ILabel getCellInRow5Column3() {
57-
return cellInRow5Column3;
58-
}
59-
60-
public ILabel getCellInRow1Column1() {
61-
return cellInRow1Column1;
62-
}
63-
64-
public ILabel getCellInRow2Column1() {
65-
return cellInRow2Column1;
66-
}
67-
68-
public ILabel getHeaderName() {
69-
return headerName;
70-
}
71-
72-
public String getLocatorCellRow1Column1() {
73-
return locatorCellRow1Column1;
74-
}
75-
76-
public String getLocatorCellRow5Column5() {
77-
return locatorCellRow5Column5;
78-
}
79-
80-
public String getLocatorCellRow3Column5() {
81-
return locatorCellRow3Column5;
82-
}
83-
84-
public String getLocatorCellRow7Column5() {
85-
return locatorCellRow7Column5;
86-
}
87-
88-
public String getLocatorCellRow5Column3() {
89-
return locatorCellRow5Column3;
90-
}
91-
92-
public String getLocatorCellRow5Column7() {
93-
return locatorCellRow5Column7;
94-
}
9523
}

0 commit comments

Comments
 (0)