-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArticlePageObject.java
More file actions
127 lines (117 loc) · 4.88 KB
/
ArticlePageObject.java
File metadata and controls
127 lines (117 loc) · 4.88 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
package lib.UI;
import io.qameta.allure.Step;
import lib.Platform;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;
abstract public class ArticlePageObject extends MainPageObject {
protected static String
TITLE_IN_FOLDER_TPL,
TITLE_IN_ARTICLE,
BUTTON_DELETE,
SUBTITLE_TPL;
public ArticlePageObject(RemoteWebDriver driver)
{
super(driver);
}
/*TEMPLATES METHODS */
private static String getTitleElement(String substring)
{
return TITLE_IN_FOLDER_TPL.replace("{SUBSTRING_TITLE}",substring);
}
private static String getSubTitleElement(String substring)
{
return SUBTITLE_TPL.replace("{SUBSTRING_SUBTITLE}",substring);
}
/*TEMPLATES METHODS */
@Step("Waiting for title '{substring}' in the folder")
public WebElement waitForTitleElementInFolder(String substring)
{
String element_result_present_xpath = getTitleElement(substring);
return this.waitForElementPresent(element_result_present_xpath,"Cannot find " + substring + " article in folder",7);
}
@Step("Waiting for subtitle '{substring}' on the article page")
public WebElement waitForSubTitleElement(String substring)
{
String element_result_present_xpath = getSubTitleElement(substring);
return this.waitForElementPresent(element_result_present_xpath,"Cannot find " + substring + " article in folder",7);
}
@Step("Getting for title on the article in folder (for mobile web)")
public String getArticleTitleInFolderMW()
{
screenshot(this.takeScreenshot("article_title_in_folder"));
return this.waitForElementPresent(TITLE_IN_FOLDER_TPL,"Can",3).getText();
}
@Step("Getting for title '{substring}' on the article in folder (for iOS/Android)")
public String getArticleTitleInFolder(String substring)
{
WebElement title_element_in_folder = waitForTitleElementInFolder(substring);
screenshot(this.takeScreenshot("article_title_in_folder"));
String element=null;
if (Platform.getInstance().isiOS()) {
element = title_element_in_folder.getAttribute("value");
} else if (Platform.getInstance().isAndroid()) {
element = title_element_in_folder.getAttribute("text");
} else {
element = title_element_in_folder.getText();
}
return element;
}
@Step("Getting for subtitle '{substring}' on the article")
public String getArticleSubTitle(String substring)
{
WebElement subtitle_element_in_folder = waitForSubTitleElement(substring);
String element=null;
if (Platform.getInstance().isAndroid()||Platform.getInstance().isMW()) {
element = "text";
} else if (Platform.getInstance().isiOS()) {
element = "value";
}
screenshot(this.takeScreenshot("article_subtitle"));
return subtitle_element_in_folder.getAttribute(element);
}
@Step("Waiting for title in the article")
public WebElement waitForTitleElementInArticle()
{
return this.waitForElementPresent(TITLE_IN_ARTICLE,"Cannot find title in article",10);
}
@Step("Waiting for title in the article without waiting for the title to appear")
public void waitForTitleElementInArticleWithoutTimeout()
{
this.assertElementPresent(TITLE_IN_ARTICLE,"Cannot find title in article");
}
@Step("Getting for title on the article (for iOS/Android)")
public String getTitleInArticle()
{
WebElement title_element = waitForTitleElementInArticle();
String element=null;
if (Platform.getInstance().isMW()) {
element = title_element.getText();
} else {
element = title_element.getAttribute("value");
}
screenshot(this.takeScreenshot("title_in_article"));
return element;
}
@Step("Getting for title on the article (for mobile web)")
public String getTitleInArticleMW ()
{
screenshot(this.takeScreenshot("title_in_article"));
return this.waitForElementPresent(TITLE_IN_ARTICLE,"Can2",3).getText();
}
@Step("Swiping article '{substring}' for delete")
public void swipeElementDelete(String substring)
{
this.waitForArticleToAppearByTitle(substring);
String element_for_swipe = getTitleElement(substring);
this.swipeElementToLeft(element_for_swipe,"Cannot find " + substring + " article in saved folder");
if (Platform.getInstance().isiOS()) {
this.waitForElementAndClick(BUTTON_DELETE,"Cannot fine delete button",5);
}
}
@Step("Waiting for article by '{substring}'")
public void waitForArticleToAppearByTitle(String substring)
{
String article_xpath = getTitleElement(substring);
this.waitForElementPresent(article_xpath,"Cannot find saved article by title " + substring,15);
}
}