-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.page.js
54 lines (42 loc) · 1.29 KB
/
main.page.js
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
const Page = require('./page');
class MainPage extends Page {
get linkNewArticle() {
return $('a[routerlink="/editor"]');
}
get linkGlobalFeed() {
return $('//a[.=" Global Feed "]');
}
get linkArticlePreview() {
return $$('//a[@class="preview-link"]/h1');
}
get paginationModule() {
return $('.pagination')
}
async openNewArticle () {
await this.linkNewArticle.click();
}
async openGlobalFeed (){
await this.linkGlobalFeed.click();
}
async getAllTitlesFromPage (){
// wait is here just to show that I know about its existence
await this.paginationModule.waitForDisplayed({ timeout: 1000 });
const elements = await this.linkArticlePreview;
console.log('Found ' + elements.length + ' elements')
const titles = await this.promToArr(elements)
console.log('Article titles: ' + titles)
return titles
}
async openArticle(title){
await $(`//a[@class="preview-link"]/h1[.="${title}"]`).click()
}
async promToArr( elements ){
const tt = []
for (const element of elements){
const text = await element.getText()
tt.push(text )
}
return tt
}
}
module.exports = new MainPage();