Repository navigation
Expand file tree
/
Copy pathMyListsPageObject.java
More file actions
87 lines (70 loc) · 2.83 KB
/
Copy pathMyListsPageObject.java
File metadata and controls
87 lines (70 loc) · 2.83 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
package lib.ui;
import lib.Platform;
import org.openqa.selenium.remote.RemoteWebDriver;
abstract public class MyListsPageObject extends MainPageObject {
protected static String
FOLDER_BY_NAME_TPL,
ARTICLE_BY_TITLE_TPL,
REMOVE_FROM_SAVED_BUTTON;
private static String getFolderXpathByName(String name_of_folder) {
return FOLDER_BY_NAME_TPL.replace("{FOLDER_NAME}", name_of_folder);
}
private static String getSavedArticleByTitle(String article_title) {
return ARTICLE_BY_TITLE_TPL.replace("{TITLE}", article_title);
}
private static String getRemoveButtonByTitle(String article_title) {
return REMOVE_FROM_SAVED_BUTTON.replace("{TITLE}", article_title);
}
public MyListsPageObject(RemoteWebDriver driver) {
super(driver);
}
public void openFolderByName(String name_of_folder) {
String folder_name_xpath = getFolderXpathByName(name_of_folder);
this.waitForElementAndClick(
folder_name_xpath,
"Cannot find folder by name " + name_of_folder,
6
);
}
public void waitForArticleToAppearByTitle(String article_title) {
String article_xpath = getSavedArticleByTitle(article_title);
this.waitForElementPresent(
article_xpath,
"Cannot find saved article by title " + article_title,
15
);
}
public void waitForArticleToDisappearByTitle(String article_title) {
String article_xpath = getSavedArticleByTitle(article_title);
this.waitForElementNotPresent(
article_xpath,
"Saved article still present with title " + article_title,
15
);
}
public void swipeByArticleToDelete(String article_title) {
this.waitForArticleToAppearByTitle(article_title);
String article_xpath = getSavedArticleByTitle(article_title);
if (Platform.getInstance().isAndroid() || Platform.getInstance().isIOS()) {
this.swipeElementToLeft(
article_xpath,
"Cannot find saved article"
);
} else {
String remove_locator = getRemoveButtonByTitle(article_title);
this.waitForElementAndClick(
remove_locator,
"Cannot click button to remove article from saved.",
10
);
this.waitForElementNotPresent(remove_locator, "Remove button is still present!", 5);
}
if (Platform.getInstance().isIOS()) {
this.clickElementToTheRightCorner(article_xpath, "Cannot find saved article");
}
if (Platform.getInstance().isMW()) {
driver.navigate().refresh();
}
this.waitForArticleToDisappearByTitle(article_title);
}
}