From e5c1edbef7031a3894466b0691b423a4d8942543 Mon Sep 17 00:00:00 2001 From: charanya-QA Date: Wed, 9 Oct 2024 16:58:59 -0700 Subject: [PATCH] Changes with respect to WV-421 First Pass of How it works Page Automation Test Cases: Web --- .../capabilities/testData.js | 8 + .../config/wdio.config.js | 1 + .../page_objects/howitworks.js | 140 +++++++++- .../specs/HowItWorks.js | 250 +++++++++++++----- 4 files changed, 334 insertions(+), 65 deletions(-) create mode 100644 tests/browserstack_automation/capabilities/testData.js diff --git a/tests/browserstack_automation/capabilities/testData.js b/tests/browserstack_automation/capabilities/testData.js new file mode 100644 index 000000000..58a01c04f --- /dev/null +++ b/tests/browserstack_automation/capabilities/testData.js @@ -0,0 +1,8 @@ +module.exports = { + MOBILE_NUMBER: '808-935-8555', + MOBILE_VERIFICATION: '123456', + EMAIL_NEGATIVE_SCENARIO: 'wevote@wevote.us', + INVALID_MOBILE_NUMBER: '808-935-855', + INVALID_EMAIL_ADDRESS: 'wevote@wevote', + UNVERIFIED_PHONE_NUMBER: '808-935-8554' +}; diff --git a/tests/browserstack_automation/config/wdio.config.js b/tests/browserstack_automation/config/wdio.config.js index 45e9efe0d..1d7f059ee 100644 --- a/tests/browserstack_automation/config/wdio.config.js +++ b/tests/browserstack_automation/config/wdio.config.js @@ -42,6 +42,7 @@ module.exports.config = { '../specs/ReadyPage.js', '../specs/TermsPage.js', '../specs/TopNavigation.js', + '../specs/HowItWorks.js', ], capabilities, commonCapabilities: { diff --git a/tests/browserstack_automation/page_objects/howitworks.js b/tests/browserstack_automation/page_objects/howitworks.js index 1ca5075ff..0a264e789 100644 --- a/tests/browserstack_automation/page_objects/howitworks.js +++ b/tests/browserstack_automation/page_objects/howitworks.js @@ -1,15 +1,145 @@ import { $ } from '@wdio/globals'; import Page from './page'; +class HowItWorks extends Page { + get howItWorksTitle () { + return $('div>h3[class~="gNNNpX"]'); + } -class HowItWorks extends Page { - get FirstModalbutton () { - return $('(//div[@p = "How WeVote works"])'); + get findNextButtonHowItWorksWindow () { + return $('.kMeOcV'); + } + + get findBackButtonHowItWorksWindow () { + return $('//button[text() = "Back"]'); + } + + get getTitleSignUpPopUp () { + return $('.u-f3'); + } + + get getStartedButton () { + return $('.cqTvJR>button'); + } + + get enterVoterEmailAddressTextBox () { + return $('#enterVoterEmailAddress'); + } + + get cancelEmailButton () { + return $('#cancelEmailButton'); + } + + get cancelMobilePhoneNumberButton(){ + return $('#cancelVoterPhoneSendSMS') + } + + get enterMobilePhoneNumber() { + return $('#enterVoterPhone'); + } + + get enterSignInWithApple() { + return $('#appleLogo'); + } + + get enterSignInWithTwitter () { + return $('.csbvaL'); + } + + get cancelTwitterSignin(){ + return $('#cancel') + } + + get gotoWeVoteBallotGuide() { + return $('*=homepage') + } + + get enterSendVerificationCode() { + return $('#desktopSmsSendCode') + } + + get enterSendEmailVerificationCode() { + return $('#voterEmailAddressEntrySendCode') + } + + get enterVerifyButton(){ + return $('#emailVerifyButton') + } + + get enterProfileAvatar(){ + return $('#profileAvatarHeaderBar') + } + + get phoneNumberHelperText(){ + return $('#enterVoterPhone-helper-text') + } + + get emailAddressHelperText() { + return $('#enterVoterEmailAddress-helper-text') + } + + get backArrow() { + return $('#emailVerificationBackButton') + } + + get deleteIcon() { + return $('svg[data-testid="DeleteIcon"]') + } + + get alertMessage() { + return $('.MuiAlert-message') + } + + async enterDigit(num){ + if (num === 0) { + return $('#digit1') + }else if (num === 1) { + return $('#digit2') + } else if (num === 2) { + return $('#digit3') + } else if (num === 3) { + return $('#digit4') + } else if (num == 4) { + return $('#digit5') + } else{ + return $('#digit6') + } + + } + + async clickButton(element){ + await element.findAndClick() + } + + async scrollToView(element) { + await element.scrollIntoView() + } + + async clickNextButtonFourTimes () { + for (let i = 1; i <= 4; i++) { + await this.findNextButtonHowItWorksWindow.click(); + } + } + + async clickBackButtonFourTimes () { + for (let i = 1; i <= 4; i++) { + await this.findBackButtonHowItWorksWindow.click(); + } } - get modalTitle () { - return $('.3Title-sc-1rpx53i-1 iavXrP'); + async checkTitleOfHowItWorksWindow (num) { + if (num === 1) { + return '1. Choose your interests'; + }else if (num === 2) { + return '2. Follow organizations and people you trust'; + } else if (num === 3) { + return '3. See who endorsed each choice on your ballot'; + } else if (num === 4) { + return '4. Complete your ballot with confidence'; + } else { + return '5. Share with friends who could use a guide'; + } } } diff --git a/tests/browserstack_automation/specs/HowItWorks.js b/tests/browserstack_automation/specs/HowItWorks.js index 6de88d1b4..c17f4bc85 100644 --- a/tests/browserstack_automation/specs/HowItWorks.js +++ b/tests/browserstack_automation/specs/HowItWorks.js @@ -1,73 +1,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 { describe, it } = require('mocha'); - +const testData = require('../capabilities/testData.js'); const waitTime = 5000; - - describe('HowItWorks', () => { // HowItWorks_001 - it('verifyHowItWorksModalWindowOpen', async () => { + it('verifyNextButton', async () => { await ReadyPage.load(); await driver.pause(waitTime); - await TopNavigation.getBallotLinkLocator.click(); - await driver.waitUntil(async () => { - // Add condition to check for the expected URL - const currentUrl = await driver.getUrl(); - console.log(currentUrl); - return currentUrl.includes('ballot'); - }, { - timeout: 10000, - timeoutMsg: 'Expected URL to contain "ballot" not found, timeout after 10000ms', - }); - await HowItWorks.FirstModalbutton.click(); - await expect(HowItWorks.modalTitle).toBeDisplayed(); + 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") }); - // it('verifyHowItWorksModalWindowClosed', async () => { - // await ReadyPage.load(); - // await driver.pause(waitTime); - // await ReadyPage.clickHowItWorksLink(); - // await driver.pause(waitTime); - // await ReadyPage.howItWorksTitle.isDisplayed(); - // await ReadyPage.closeHowItWorksModalWindow(); - // await driver.pause(waitTime); - // await expect(ReadyPage.elementHowItWorksWindow).not.toBeDisplayed(); - // }); - - // // Ready_012 - // it('verifyHowItWorksModalWindowNextButton', async () => { - // await ReadyPage.load(); - // await driver.pause(waitTime); - // await ReadyPage.clickHowItWorksLink(); - // await driver.pause(waitTime); - // const expectedResult = await ReadyPage.checkTitleOfHowItWorksWindow(); - // await expect(ReadyPage.howItWorksTitle).toHaveText(expectedResult); - // }); - - // // Ready_013 - // it('verifyHowItWorksModalWindowNextGetStartedButton', async () => { - // await ReadyPage.load(); - // await ReadyPage.clickHowItWorksLink(); - // await driver.pause(waitTime); - // await ReadyPage.clickNextButtonFourTimes(); - // await driver.pause(waitTime); - // await ReadyPage.clickGetStartedButton(); - // await driver.pause(waitTime); - // await expect(ReadyPage.getTitleSignUpPopUp).toHaveText('Sign In or Join'); - // }); + // 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") + }); - // // Ready_014 - // it('verifyHowItWorksModalWindowBackButton', async () => { - // await ReadyPage.load(); - // await driver.pause(waitTime); - // await ReadyPage.clickHowItWorksLink(); - // await driver.pause(waitTime); - // const expectedResult = await ReadyPage.getTitleOfHowItWorksWindowAfterBackButton(); - // await expect(ReadyPage.howItWorksTitle).toHaveText(expectedResult); - // }); });