forked from wevote/WebApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcandidates.page.js
95 lines (76 loc) · 2.75 KB
/
candidates.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
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
import { $, $$, driver } from '@wdio/globals';
import Page from './page';
import TopNavigation from './topnavigation';
class CandidatesPage extends Page {
async load () {
await super.open('');
await driver.maximizeWindow();
await TopNavigation.toggleCandidatesTab();
}
get stateSelect () {
return $("//select[@id='outlined-age-native-simple']");
}
get stateSelectOptions () {
return $$("//select[@id='outlined-age-native-simple']//option");
}
get pageHeaders () {
return $$('h2#whatIsHappeningTitle');
}
get candidateCardList () {
return $$("//div[contains(@id,'cardForListBodyWrapper')]");
}
get candidateSupportButtonList () {
return $$("button[id*='itemActionBarSupportButton'][id*='desktop']");
}
get supportTooltip () {
return $('div#supportButtonTooltip');
}
get opposeTooltip () {
return $('div#opposeButtonTooltip');
}
get scrollRight () {
return $('div#candidateRightArrowDesktop');
}
async getCandidateCardCandidateName(cardId) {
const candidate = await $(`//div[@id='${cardId}']//a[@id='candidateCardDisplayName' or @id='representativeCardDisplayName']`);
const candidateName = await candidate.getText();
return candidateName;
}
async getCandidateCardState(cardId) {
const candidate = await $(`//div[@id='${cardId}']//div[contains(@id,'stateName')]`);
const stateText = await candidate.getText();
return stateText;
}
async getCandidateCardPartyName (cardId) {
const candidateParty = await $(`//div[@id='${cardId}']//div[contains(@class,'PoliticalParty')]`);
const candidatePartyExists = await candidateParty.isExisting();
if (candidatePartyExists) {
const partyText = await candidateParty.getText();
return partyText;
} else {
return null;
}
}
async getCandidateCardOffice (cardId) {
const candidateOffice = await $(`//div[@id='${cardId}']//div[contains(@class,'OfficeNameWrapper')]/div`);
const officeText = candidateOffice.getText();
return officeText;
}
async getCandidateCardImage (cardId) {
const candidateImage = await $(`//div[@id='${cardId}']//div[@id='candidateCardPhotoDesktop']/div/img`);
return candidateImage;
}
async getCandidateCardChoose (cardId) {
return $(`div#${cardId} button[id*='itemActionBarSupport'][id*='desktop']`);
}
async getCandidateCardOppose (cardId) {
return $(`div#${cardId} button[id*='itemActionBarOppose'][id*='desktop']`);
}
async getCandidateCardHelpWinButton (cardId) {
return $(`div#${cardId} button[id*='itemActionBarHelpThemWinButton'][id*='desktop']`);
}
async getCandidateCardHelpDefeatButton (cardId) {
return $(`div#${cardId} button[id*='itemActionBarHelpDefeatButton'][id*='desktop']`);
}
}
export default new CandidatesPage();