forked from wevote/WebApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HowItWorks.js
203 lines (201 loc) · 9.11 KB
/
HowItWorks.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import { driver, expect } from '@wdio/globals';
import ReadyPage from '../page_objects/ready.page';
import TopNavigation from '../page_objects/topnavigation';
import HowItWorks from '../page_objects/howitworks';
const testData = require('../capabilities/testData.js');
const waitTime = 5000;
describe('HowItWorks', () => {
// HowItWorks_001
it('verifyNextButton', async () => {
await ReadyPage.load();
await driver.pause(waitTime);
await ReadyPage.clickHowItWorksLink();
await driver.pause(waitTime);
for (let i = 1; i < 6; i++) {
const expectedResult = await HowItWorks.checkTitleOfHowItWorksWindow(i);
await expect(HowItWorks.howItWorksTitle).toHaveText(expectedResult);
if (i!= 5) {
const nextButton = await HowItWorks.findNextButtonHowItWorksWindow;
await HowItWorks.clickButton(nextButton)
}
}
console.log("Next Button and titles of the page verified successfully")
});
// HowItWorks_002
it('verifyBackButton', async () => {
await ReadyPage.load();
await driver.pause(waitTime);
await ReadyPage.clickHowItWorksLink();
await driver.pause(waitTime);
await HowItWorks.clickNextButtonFourTimes();
await HowItWorks.clickBackButtonFourTimes()
const expectedResult = await HowItWorks.checkTitleOfHowItWorksWindow(1);
await expect(HowItWorks.howItWorksTitle).toHaveText(expectedResult);
console.log("Back button clicked successfully and user is on first page")
});
// HowItWorks_003
it('verifyGetStartedButton', async () => {
await ReadyPage.load();
await ReadyPage.clickHowItWorksLink();
await driver.pause(waitTime);
await HowItWorks.clickNextButtonFourTimes();
const getStarted = await HowItWorks.getStartedButton;
await HowItWorks.clickButton(getStarted)
await driver.pause(waitTime);
await expect(HowItWorks.getTitleSignUpPopUp).toHaveText('Sign In or Join');
console.log("GetStarted Button Clicked Successfully, user on the signIn page")
});
// HowItWorks_004
it('verifyCancelSigninwithEmail', async () => {
await ReadyPage.load();
await ReadyPage.clickHowItWorksLink();
await driver.pause(waitTime);
await HowItWorks.clickNextButtonFourTimes();
const getStarted = await HowItWorks.getStartedButton;
await HowItWorks.clickButton(getStarted)
const emailTextBox = await HowItWorks.enterVoterEmailAddressTextBox;
await emailTextBox.addValue(testData.EMAIL_NEGATIVE_SCENARIO);
const cancelButton = await HowItWorks.cancelEmailButton;
await HowItWorks.clickButton(cancelButton)
console.log("Email SignIn was Cancelled")
await expect(HowItWorks.getTitleSignUpPopUp).toHaveText('Sign In or Join');
});
// HowItWorks_005
it('verifyCancelSigninWithMobile', async () => {
await ReadyPage.load();
await ReadyPage.clickHowItWorksLink();
await driver.pause(waitTime);
await HowItWorks.clickNextButtonFourTimes();
const getStarted = await HowItWorks.getStartedButton;
await HowItWorks.clickButton(getStarted)
const mobilePhoneNumber = await HowItWorks.enterMobilePhoneNumber;
await mobilePhoneNumber.addValue(testData.MOBILE_NUMBER);
const cancelButton = await HowItWorks.cancelMobilePhoneNumberButton;
await HowItWorks.clickButton(cancelButton)
await expect(HowItWorks.getTitleSignUpPopUp).toHaveText('Sign In or Join');
console.log("Mobile SignIn was Cancelled")
});
// HowItWorks_006
it('verifyCancelSigninWithApple', async () => {
await ReadyPage.load();
await ReadyPage.clickHowItWorksLink();
await driver.pause(waitTime);
await HowItWorks.clickNextButtonFourTimes();
const getStarted = await HowItWorks.getStartedButton;
await HowItWorks.clickButton(getStarted)
const signinWithAppleID = await HowItWorks.enterSignInWithApple;
await HowItWorks.clickButton(signinWithAppleID)
await driver.back() //This line won't work in Safari. Needs to be addressed after WV-557 issue is fixed
await expect(HowItWorks.getTitleSignUpPopUp).toHaveText('Sign In or Join');
console.log("AppleID SignIn was Cancelled")
});
// HowItWorks_007
it('verifyCancelSigninWithTwitter', async () => {
await ReadyPage.load();
await ReadyPage.clickHowItWorksLink();
await driver.pause(waitTime);
await HowItWorks.clickNextButtonFourTimes();
const getStarted = await HowItWorks.getStartedButton;
await HowItWorks.clickButton(getStarted)
const signinWithTwitter = await HowItWorks.enterSignInWithTwitter;
await HowItWorks.clickButton(signinWithTwitter)
const cancelButton = await HowItWorks.cancelTwitterSignin;
await HowItWorks.clickButton(cancelButton)
const gotoHomePage = await HowItWorks.gotoWeVoteBallotGuide;
await HowItWorks.clickButton(gotoHomePage)
await driver.pause(waitTime);
await expect(driver).toHaveUrl(expect.stringContaining('quality'));
console.log("Twitter SignIn was Cancelled")
});
// HowItWorks_008
it('verifySigninUsingMobile', async () => {
await ReadyPage.load();
await ReadyPage.clickHowItWorksLink();
await driver.pause(waitTime);
await HowItWorks.clickNextButtonFourTimes();
const getStarted = await HowItWorks.getStartedButton;
await HowItWorks.clickButton(getStarted)
const mobilePhoneNumber = await HowItWorks.enterMobilePhoneNumber;
await mobilePhoneNumber.addValue(testData.MOBILE_NUMBER);
const sendCode = await HowItWorks.enterSendVerificationCode;
await HowItWorks.clickButton(sendCode)
for (let i = 0; i < 6; i++) {
const digitValue = await HowItWorks.enterDigit(i);
await digitValue.addValue(testData.MOBILE_VERIFICATION[i]);
}
const verifyButton = await HowItWorks.enterVerifyButton;
await HowItWorks.clickButton(verifyButton)
const profileAvatar = await HowItWorks.enterProfileAvatar;
await HowItWorks.clickButton(profileAvatar)
console.log("User was able to successfully signIn using mobile")
});
//HowItWorks_013
it('verifyInvalidMobileNumber' , async () =>{
await ReadyPage.load();
await ReadyPage.clickHowItWorksLink();
await driver.pause(waitTime);
await HowItWorks.clickNextButtonFourTimes();
const getStarted = await HowItWorks.getStartedButton;
await HowItWorks.clickButton(getStarted)
const mobilePhoneNumber = await HowItWorks.enterMobilePhoneNumber;
await mobilePhoneNumber.addValue(testData.INVALID_MOBILE_NUMBER);
await driver.pause(waitTime);
await expect(HowItWorks.phoneNumberHelperText).toHaveText('Enter a valid phone number');
console.log("Invalid Mobile number error message verified")
});
//HowItWorks_014
it('VerifyInvalidEmailAddress' , async () =>{
await ReadyPage.load();
await ReadyPage.clickHowItWorksLink();
await driver.pause(waitTime);
await HowItWorks.clickNextButtonFourTimes();
const getStarted = await HowItWorks.getStartedButton;
await HowItWorks.clickButton(getStarted)
const emailTextBox = await HowItWorks.enterVoterEmailAddressTextBox;
await emailTextBox.addValue(testData.INVALID_EMAIL_ADDRESS);
await driver.pause(waitTime);
await expect(HowItWorks.emailAddressHelperText).toHaveText('Enter valid email 6 to 254 characters long');
console.log("Invalid Email Address error message verified")
});
// HowItWorks_015
it('verifyDeleteUnverifiedPhoneNumbers', async () => {
await ReadyPage.load();
await ReadyPage.clickHowItWorksLink();
await driver.pause(waitTime);
await HowItWorks.clickNextButtonFourTimes();
const getStarted = await HowItWorks.getStartedButton;
await HowItWorks.clickButton(getStarted)
const mobilePhoneNumber = await HowItWorks.enterMobilePhoneNumber;
await mobilePhoneNumber.addValue(testData.UNVERIFIED_PHONE_NUMBER);
const sendCode = await HowItWorks.enterSendVerificationCode;
await HowItWorks.clickButton(sendCode)
const backButton = await HowItWorks.backArrow;
await HowItWorks.clickButton(backButton)
const deleteButton = await HowItWorks.deleteIcon;
await driver.pause(waitTime);
await HowItWorks.clickButton(deleteButton);
await expect(HowItWorks.alertMessage).toHaveText('Your Phone number was deleted.');
console.log("Deleted unverified phone numbers")
});
// HowItWorks_016
it('verifyDeleteUnverifiedEmailAddress', async () => {
await ReadyPage.load();
await ReadyPage.clickHowItWorksLink();
await driver.pause(waitTime);
await HowItWorks.clickNextButtonFourTimes();
const getStarted = await HowItWorks.getStartedButton;
await HowItWorks.clickButton(getStarted)
const mobilePhoneNumber = await HowItWorks.enterMobilePhoneNumber;
const emailTextBox = await HowItWorks.enterVoterEmailAddressTextBox;
await emailTextBox.addValue(testData.EMAIL_NEGATIVE_SCENARIO);
const sendCode = await HowItWorks.enterSendEmailVerificationCode;
await HowItWorks.clickButton(sendCode)
const backButton = await HowItWorks.backArrow;
await HowItWorks.clickButton(backButton)
const deleteButton = await HowItWorks.deleteIcon;
await driver.pause(waitTime);
await HowItWorks.clickButton(deleteButton);
await expect(HowItWorks.alertMessage).toHaveText('Your email address was deleted.');
console.log("Deleted unverified Email address")
});
});