Repository navigation
Expand file tree
/
Copy pathSearchPageObject.java
More file actions
74 lines (57 loc) · 2.63 KB
/
Copy pathSearchPageObject.java
File metadata and controls
74 lines (57 loc) · 2.63 KB
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
package lib.ui;
import org.openqa.selenium.remote.RemoteWebDriver;
abstract public class SearchPageObject extends MainPageObject {
protected static String
SEARCH_INIT_ELEMENT,
SEARCH_INPUT,
SEARCH_CANCEL_BUTTON,
SEARCH_RESULT_BY_SUBSTRING_TPL,
SEARCH_RESULT_ELEMENT,
SEARCH_EMPTY_RESULT_ELEMENT;
public SearchPageObject(RemoteWebDriver driver) {
super(driver);
}
/* TEMPLATES METHODS */
private String getResultSearchElement(String substring) {
return SEARCH_RESULT_BY_SUBSTRING_TPL.replace("{SUBSTRING}", substring);
}
/* TEMPLATES METHODS */
public void initSearchInput() {
this.waitForElementAndClick(SEARCH_INIT_ELEMENT, "Cannot find and click search init element", 5);
this.waitForElementPresent(SEARCH_INIT_ELEMENT, "Cannot find search input after clicking search init element");
}
public void waitForCancelButtonToAppear() {
this.waitForElementPresent(SEARCH_CANCEL_BUTTON, "Cannot find search cancel button!", 5);
}
public void waitForCancelButtonToDisappear() {
this.waitForElementNotPresent(SEARCH_CANCEL_BUTTON, "Search cancel button is still present!", 5);
}
public void clickCancelSearch() {
this.waitForElementAndClick(SEARCH_CANCEL_BUTTON, "Cannot find and click search cancel button!", 5);
}
public void typeSearchLine(String search_line) {
this.waitForElementAndSendKeys(SEARCH_INPUT, search_line, "Cannot find and type into search input", 5);
}
public void waitForSearchResult(String substring) {
String search_result_xpath = getResultSearchElement(substring);
this.waitForElementPresent(search_result_xpath, "Cannot find search result with substring " + substring, 15);
}
public void clickByArticleWithSubstring(String substring) {
String search_result_xpath = getResultSearchElement(substring);
this.waitForElementAndClick(search_result_xpath, "Cannot find and click search result with substring " + substring, 10);
}
public int getAmountOfFoundArticles() {
this.waitForElementPresent(
SEARCH_RESULT_ELEMENT,
"Cannot find anything by request",
15
);
return this.getAmountOfElements(SEARCH_RESULT_ELEMENT);
}
public void waitForEmptyResultsLabel() {
this.waitForElementPresent(SEARCH_EMPTY_RESULT_ELEMENT, "Cannot find empty result element.", 15);
}
public void assertThereIsNoResultOfSearch() {
this.assertElementNotPresent(SEARCH_RESULT_ELEMENT, "We supposed not to find any results");
}
}