Skip to content

Commit

Permalink
WV-860 ID changes and test script changes for How it Works
Browse files Browse the repository at this point in the history
  • Loading branch information
charanya-QA committed Dec 6, 2024
1 parent ecd6d9a commit 54c5cd5
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 60 deletions.
3 changes: 2 additions & 1 deletion tests/browserstack_automation/capabilities/testData.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ module.exports = {
EMAIL_NEGATIVE_SCENARIO: '[email protected]',
INVALID_MOBILE_NUMBER: '808-935-855',
INVALID_EMAIL_ADDRESS: 'wevote@wevote',
UNVERIFIED_PHONE_NUMBER: '808-935-8554'
UNVERIFIED_PHONE_NUMBER: '808-935-8554',
EMAIL_VALID:'[email protected]'
};
112 changes: 82 additions & 30 deletions tests/browserstack_automation/page_objects/howitworks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,44 @@ import { driver, expect } from '@wdio/globals';

class HowItWorks extends Page {

get howItWorksTitle () {
return $('div>h3[class~="gNNNpX"]');
get howItWorksTitle1() {
return $('#claimYourCampaignProfile')
}
get howItWorksDescription () {
return $('div>p[class~="ejpinv"]');

get howItWorksTitle2() {
return $('#importEndorsements')
}

get howItWorksTitle3() {
return $('#addMoreCustomizations')
}

get howItWorksTitle4() {
return $('#launchToYourPeople')
}

get howItWorksTitle5() {
return $('#socialLift')
}

get howItWorksDescription1() {
return $('#claimYourCampaignProfileDescription');
}

get howItWorksDescription2() {
return $('#importEndorsementsDescription');
}

get howItWorksDescription3() {
return $('#addMoreCustomizationsDescription');
}

get howItWorksDescription4() {
return $('#launchToYourPeopleDescription');
}

get howItWorksDescription5() {
return $('#socialLiftDescription');
}

get howItWorksImage () {
Expand All @@ -34,12 +67,28 @@ class HowItWorks extends Page {
return $('#annotatedSlideShowStep4Next');
}

get findBackButtonHowItWorksWindow () {
return $('//button[text() = "Back"]');
get findFirstBackButtonHowItWorksWindow () {
return $('#annotatedSlideShowStep2Back');
}

get findSecondBackButtonHowItWorksWindow () {
return $('#annotatedSlideShowStep3Back');
}

get findThirdBackButtonHowItWorksWindow () {
return $('#annotatedSlideShowStep4Back');
}

get findFourthBackButtonHowItWorksWindow () {
return $('#howItWorksBackDesktopButton');
}

get getTitleSignUpPopUp () {
return $('.u-f3');
return $('#signIn');
}

get signInSubtitle (){
return $('#pleaseSingInTitle')
}

get getStartedButton () {
Expand Down Expand Up @@ -67,17 +116,13 @@ class HowItWorks extends Page {
}

get enterSignInWithTwitter () {
return $('.csbvaL');
return $('.csbvaL');//deprecated case page object
}

get cancelTwitterSignin(){
return $('#cancel')
}

get gotoWeVoteBallotGuide() {
return $('*=homepage')
}

get enterSendVerificationCode() {
return $('#desktopSmsSendCode')
}
Expand All @@ -94,6 +139,10 @@ class HowItWorks extends Page {
return $('#profileAvatarHeaderBar')
}

get signOut() {
return $('#signOut_Settings')
}

get phoneNumberHelperText(){
return $('#enterVoterPhone-helper-text')
}
Expand All @@ -107,7 +156,7 @@ class HowItWorks extends Page {
}

get deleteIcon() {
return $('svg[data-testid="DeleteIcon"]')
return $('svg[data-testid = "DeleteIcon"]')
}

get alertMessage() {
Expand Down Expand Up @@ -135,10 +184,6 @@ class HowItWorks extends Page {
await element.findAndClick()
}

async scrollToView(element) {
await element.scrollIntoView()
}

async clickHowItWorksLink () {
await this.howItWorksLink .click();
}
Expand Down Expand Up @@ -169,18 +214,17 @@ class HowItWorks extends Page {
}
}


async checkDescriptionOfHowItWorksWindow (num) {
if (num === 1) {
return 'Follow topics that interest you. We will suggest endorsements based on your interests.';
return this.howItWorksDescription1;
}else if (num === 2) {
return 'Learn from the people you trust. Their recommendations are highlighted on your ballot.';
return this.howItWorksDescription2;
} else if (num === 3) {
return 'Your personalized score for a candidate is the number of people who support the candidate, from among the people you follow.';
return this.howItWorksDescription3;
} else if (num === 4) {
return 'WeVote is fast, mobile, and helps you decide on the go. Vote with confidence!';
return this.howItWorksDescription4;
} else {
return 'Are your family and friends feeling lost when it\'s time to vote? Be their hero, no matter which state they vote in.';
return howItWorksDescription5;
}
}

Expand All @@ -194,23 +238,31 @@ class HowItWorks extends Page {
}
}

async clickBackButtonFourTimes () {
async clickBackButtonFourTimes () {
for (let i = 1; i <= 4; i++) {
await this.findBackButtonHowItWorksWindow.click();
if (i == 1) {
await this.findFourthBackButtonHowItWorksWindow.click();
}else if (i ==2){
await this.findThirdBackButtonHowItWorksWindow.click();
}else if (i ==3){
await this.findSecondBackButtonHowItWorksWindow.click();
}else {
await this.findFirstBackButtonHowItWorksWindow.click();
}
}
}

async checkTitleOfHowItWorksWindow (num) {
if (num === 1) {
return '1. Choose your interests';
return this.howItWorksTitle1;
}else if (num === 2) {
return '2. Follow organizations and people you trust';
return this.howItWorksTitle2;
} else if (num === 3) {
return '3. See who endorsed each choice on your ballot';
return this.howItWorksTitle3;
} else if (num === 4) {
return '4. Complete your ballot with confidence';
return this.howItWorksTitle4;
} else {
return '5. Share with friends who could use a guide';
return this.howItWorksTitle5;
}
}
}
Expand Down
62 changes: 33 additions & 29 deletions tests/browserstack_automation/specs/HowItWorks.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ describe('HowItWorks', () => {
await HowItWorks.clickHowItWorksLink();
await driver.pause(waitTime);
for (let i = 1; i < 6; i++) {
const expectedResult = await HowItWorks.checkTitleOfHowItWorksWindow(i);
await expect(HowItWorks.howItWorksTitle).toHaveText(expectedResult);
await HowItWorks.checkTitleOfHowItWorksWindow(i).isExisting;
if (i!= 5) {
await HowItWorks.clickNextButton(i)
}
Expand All @@ -29,8 +28,7 @@ describe('HowItWorks', () => {
await driver.pause(waitTime);
await HowItWorks.clickNextButtonFourTimes();
await HowItWorks.clickBackButtonFourTimes()
const expectedResult = await HowItWorks.checkTitleOfHowItWorksWindow(1);
await expect(HowItWorks.howItWorksTitle).toHaveText(expectedResult);
await HowItWorks.checkTitleOfHowItWorksWindow(1).isExisting;
console.log("Back button clicked successfully and user is on first page")
});
// HowItWorks_003
Expand All @@ -42,7 +40,7 @@ describe('HowItWorks', () => {
const getStarted = await HowItWorks.getStartedButton;
await HowItWorks.clickButton(getStarted)
await driver.pause(waitTime);
await expect(HowItWorks.getTitleSignUpPopUp).toHaveText('Sign In or Join');
await expect(HowItWorks.signInSubtitle).toHaveText('Sign In or Join');
console.log("GetStarted Button Clicked Successfully, user on the signIn page")
});
// HowItWorks_004
Expand All @@ -57,8 +55,9 @@ describe('HowItWorks', () => {
await emailTextBox.addValue(testData.EMAIL_NEGATIVE_SCENARIO);
const cancelButton = await HowItWorks.cancelEmailButton;
await HowItWorks.clickButton(cancelButton)
await emailTextBox.addValue(testData.EMAIL_NEGATIVE_SCENARIO);
await expect(HowItWorks.signInSubtitle).toHaveText('Sign In or Join');
console.log("Email SignIn was Cancelled")
await expect(HowItWorks.getTitleSignUpPopUp).toHaveText('Sign In or Join');
});
// HowItWorks_005
it('verifyCancelSigninWithMobile', async () => {
Expand All @@ -72,7 +71,8 @@ describe('HowItWorks', () => {
await mobilePhoneNumber.addValue(testData.MOBILE_NUMBER);
const cancelButton = await HowItWorks.cancelMobilePhoneNumberButton;
await HowItWorks.clickButton(cancelButton)
await expect(HowItWorks.getTitleSignUpPopUp).toHaveText('Sign In or Join');
await mobilePhoneNumber.addValue(testData.MOBILE_NUMBER);
await expect(HowItWorks.signInSubtitle).toHaveText('Sign In or Join');
console.log("Mobile SignIn was Cancelled")
});
// HowItWorks_006
Expand All @@ -86,11 +86,11 @@ describe('HowItWorks', () => {
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');
await expect(HowItWorks.getTitleSignUpPopUp).toHaveText('Sign In');
console.log("AppleID SignIn was Cancelled")
});
// HowItWorks_007
it('verifyCancelSigninWithTwitter', async () => {
// HowItWorks_007 Deprecating this case
/*it('verifyCancelSigninWithTwitter', async () => {
await ReadyPage.load();
await HowItWorks.clickHowItWorksLink();
await driver.pause(waitTime);
Expand All @@ -106,7 +106,7 @@ describe('HowItWorks', () => {
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();
Expand All @@ -127,6 +127,8 @@ describe('HowItWorks', () => {
await HowItWorks.clickButton(verifyButton)
const profileAvatar = await HowItWorks.enterProfileAvatar;
await HowItWorks.clickButton(profileAvatar)
const signOutButton = await HowItWorks.signOut;
await HowItWorks.clickButton(signOutButton)
console.log("User was able to successfully signIn using mobile")
});
// HowItWorks_009
Expand All @@ -137,10 +139,9 @@ describe('HowItWorks', () => {
await HowItWorks.clickNextButtonFourTimes();
const getStarted = await HowItWorks.getStartedButton;
await HowItWorks.clickButton(getStarted)
await driver.pause(waitTime);
const emailTextBox = await HowItWorks.enterVoterEmailAddressTextBox;
await driver.pause(waitTime); //Charanya
await emailTextBox.addValue(testData.EMAIL_VALID);
await driver.pause(waitTime);
const sendCode = await HowItWorks.enterSendEmailVerificationCode;
await HowItWorks.clickButton(sendCode)
for (let i = 0; i < 6; i++) {
Expand All @@ -151,17 +152,18 @@ describe('HowItWorks', () => {
await HowItWorks.clickButton(verifyButton)
const profileAvatar = await HowItWorks.enterProfileAvatar;
await HowItWorks.clickButton(profileAvatar)
const signOutButton = await HowItWorks.signOut;
await HowItWorks.clickButton(signOutButton)
console.log("User was able to successfully signIn using Email")
});
// HowItWorks_012
it('verifyImagesAndContent', async () => {
await ReadyPage.load();
await driver.pause(waitTime);
await HowItWorks.clickHowItWorksLink(); //Charanya
await HowItWorks.clickHowItWorksLink();
await driver.pause(waitTime);
for (let i = 1; i < 6; i++) {
const expectedResult = await HowItWorks.checkDescriptionOfHowItWorksWindow(i);
await expect(HowItWorks.howItWorksDescription).toHaveText(expectedResult);
await HowItWorks.checkDescriptionOfHowItWorksWindow(i).isExisting;
await HowItWorks.checkBrokenImagesUsingResponseCode()
if (i!= 5) {
await HowItWorks.clickNextButton(i)
Expand Down Expand Up @@ -198,46 +200,48 @@ describe('HowItWorks', () => {
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 () => {

// HowItWorks_016
it('verifyDeleteUnverifiedEmailAddress', async () => {
await ReadyPage.load();
await HowItWorks.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;
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 Phone number was deleted.');
console.log("Deleted unverified phone numbers")
await expect(HowItWorks.alertMessage).toHaveText('Your email address was deleted.');
console.log("Deleted unverified Email address")
});
// HowItWorks_016
it('verifyDeleteUnverifiedEmailAddress', async () => {

// HowItWorks_015 not working because of a defect WV-572
it('verifyDeleteUnverifiedPhoneNumbers', async () => {
await ReadyPage.load();
await HowItWorks.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 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 email address was deleted.');
console.log("Deleted unverified Email address")
await expect(HowItWorks.alertMessage).toHaveText('Your Phone number was deleted.');
console.log("Deleted unverified phone numbers")
});

});

0 comments on commit 54c5cd5

Please sign in to comment.