-
Notifications
You must be signed in to change notification settings - Fork 861
/
sessionPage.js
105 lines (80 loc) · 2.78 KB
/
sessionPage.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
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
/* eslint-disable no-empty-label */
'use strict';
const BasePage = require('./basePage.js');
const By = require('selenium-webdriver').By;
const sessionPage = Object.create(BasePage);
sessionPage.getSessionTitle = function() {
const self = this;
const titleId = 'title-1090';
const sessionPromise = new Promise(function(resolve) {
const title = self.find(By.id(titleId)).getText();
resolve(title);
});
return sessionPromise;
};
sessionPage.getSessionBackgroundColor = function() {
const self = this;
const titleId = 'title-1090';
const sessionPromise = new Promise(function(resolve) {
const backgroundColor = self.find(By.id(titleId)).getCssValue('background-color');
resolve(backgroundColor);
});
return sessionPromise;
};
sessionPage.getSpeakerName = function() {
const self = this;
const speaker = 'desc-speaker-name';
const sessionPromise = new Promise(function(resolve) {
const title = self.find(By.className(speaker)).getText();
resolve(title);
});
return sessionPromise;
};
sessionPage.jumpToTrack = function() {
const self = this;
const trackClass = 'session-ul';
const pageVertScrollOffset = 'return window.scrollY';
const trackPromise = new Promise(function(resolve) {
self.find(By.className(trackClass)).then(function(elem) {
elem.findElement(By.css('a')).click().then(self.getPageUrl.bind(self))
.then(function(url) {
self.driver.executeScript(pageVertScrollOffset).then(function(height) {
resolve(height > 0 && url.search('tracks') !== -1);
});
});
});
});
return trackPromise;
};
sessionPage.jumpToSpeaker = function() {
const self = this;
const speakerClass = 'session-speakers-list';
const pageVertScrollOffset = 'return window.scrollY';
const speakerPromise = new Promise(function(resolve) {
self.find(By.className(speakerClass)).then(function(elem) {
elem.findElement(By.css('a')).click().then(self.getPageUrl.bind(self))
.then(function(url) {
self.driver.executeScript(pageVertScrollOffset).then(function(height) {
resolve(height > 0 && url.search('speakers') !== -1);
});
});
});
});
return speakerPromise;
};
sessionPage.jumpToRoom = function() {
const self = this;
const pageVertScrollOffset = 'return window.scrollY';
const roomPromise = new Promise(function(resolve) {
self.find(By.css("a[href='../rooms.html#2017-06-30-Plaza_Room_B']")).then(function(elem) {
elem.click().then(self.getPageUrl.bind(self))
.then(function(url) {
self.driver.executeScript(pageVertScrollOffset).then(function(height) {
resolve(height > 0 && url.search('rooms') !== -1);
});
});
});
});
return roomPromise;
};
module.exports = sessionPage;