Repository navigation
Expand file tree
/
Copy pathArticlePageObject.java
More file actions
137 lines (118 loc) · 4.16 KB
/
Copy pathArticlePageObject.java
File metadata and controls
137 lines (118 loc) · 4.16 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package lib.ui;
import lib.Platform;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;
abstract public class ArticlePageObject extends MainPageObject {
protected static String
TITLE,
FOOTER_ELEMENT,
OPTIONS_BUTTON,
OPTIONS_ADD_TO_MY_LIST_BUTTON,
OPTIONS_REMOVE_FROM_MY_LIST_BUTTON,
ADD_TO_MY_LIST_OVERLAY,
MY_LIST_NAME_INPUT,
MY_LIST_OK_BUTTON,
CLOSE_ARTICLE_BUTTON;
public ArticlePageObject(RemoteWebDriver driver) {
super(driver);
}
public WebElement waitForTitleElement() {
return this.waitForElementPresent(TITLE, "Cannot find article title on page", 15);
}
public String getArticleTitle() {
WebElement title_element = waitForTitleElement();
if (Platform.getInstance().isAndroid()) {
return title_element.getAttribute("text");
} else if (Platform.getInstance().isIOS()) {
return title_element.getAttribute("name");
} else {
return title_element.getText();
}
}
public void swipeToFooter() {
if (Platform.getInstance().isAndroid()) {
this.swipeUpToFindElement(
FOOTER_ELEMENT,
"Cannot find the end of article",
80);
} else if (Platform.getInstance().isIOS()) {
this.swipeUpTitleElementAppear(
FOOTER_ELEMENT,
"Cannot find the end of article",
80
);
} else {
this.scrollWebPageTillElementNotVisible(
FOOTER_ELEMENT,
"Cannot find the end of article",
80
);
}
}
public void addArticleToMyList(String name_of_folder) {
this.waitForElementAndClick(
OPTIONS_BUTTON,
"Cannot find button to open article options",
5
);
this.waitForElementAndClick(
OPTIONS_ADD_TO_MY_LIST_BUTTON,
"Cannot find option to add article to reading list",
5
);
this.waitForElementAndClick(
ADD_TO_MY_LIST_OVERLAY,
"Cannot find 'Got it' tip overlay",
5
);
this.waitForElementAndClear(
MY_LIST_NAME_INPUT,
"Cannot find input to set name of article folder",
5
);
this.waitForElementAndSendKeys(
MY_LIST_NAME_INPUT,
name_of_folder,
"Cannot put text into article folder input",
5
);
this.waitForElementAndClick(
MY_LIST_OK_BUTTON,
"Cannot press OK button",
5
);
}
public void addArticlesToMySaved() {
if (Platform.getInstance().isMW()) {
this.removeArticleFromSavedIfItAdded();
}
this.waitForElementAndClick(
OPTIONS_ADD_TO_MY_LIST_BUTTON,
"Cannot find option to add article to reading list",
5);
}
public void removeArticleFromSavedIfItAdded() {
if (this.isElementPresent(OPTIONS_REMOVE_FROM_MY_LIST_BUTTON)) {
this.waitForElementAndClick(
OPTIONS_REMOVE_FROM_MY_LIST_BUTTON,
"Cannot click button to remove an article from saved",
1
);
this.waitForElementPresent(
OPTIONS_ADD_TO_MY_LIST_BUTTON,
"Cannot find button to add an article to saved list after removing it from list before"
);
}
}
public void closeArticle() {
if (Platform.getInstance().isAndroid() || Platform.getInstance().isIOS()) {
this.waitForElementAndClick(
CLOSE_ARTICLE_BUTTON,
"Cannot close article, cannot find X link",
5
);
} else {
System.out.println("Method closeArticle() do nothing for platform " + Platform.getInstance().getPlatformVar());
}
}
}