From 49ae421564156f601ff183f33f9337f08b2e8447 Mon Sep 17 00:00:00 2001 From: charanya-QA Date: Tue, 3 Dec 2024 12:39:02 -0800 Subject: [PATCH] WV-421 Implemented HowItWorks_009 - HowItWorks_012 [Web] test cases --- .../page_objects/howitworks.js | 80 ++++++++++++++++++- .../specs/HowItWorks.js | 68 ++++++++++++---- 2 files changed, 130 insertions(+), 18 deletions(-) diff --git a/tests/browserstack_automation/page_objects/howitworks.js b/tests/browserstack_automation/page_objects/howitworks.js index 0a264e789..834627492 100644 --- a/tests/browserstack_automation/page_objects/howitworks.js +++ b/tests/browserstack_automation/page_objects/howitworks.js @@ -1,14 +1,37 @@ import { $ } from '@wdio/globals'; import Page from './page'; +import { driver, expect } from '@wdio/globals'; class HowItWorks extends Page { get howItWorksTitle () { return $('div>h3[class~="gNNNpX"]'); } + get howItWorksDescription () { + return $('div>p[class~="ejpinv"]'); + } + + get howItWorksImage () { + return $('div>img').getAttribute('src') + } + get howItWorksLink () { + return $('#footerLinkHowItWorks'); + } - get findNextButtonHowItWorksWindow () { - return $('.kMeOcV'); + get findFirstNextButtonHowItWorksWindow () { + return $('#annotatedSlideShowStep1Next'); + } + + get findSecondNextButtonHowItWorksWindow () { + return $('#annotatedSlideShowStep2Next'); + } + + get findThirdNextButtonHowItWorksWindow () { + return $('#annotatedSlideShowStep3Next'); + } + + get findFourthNextButtonHowItWorksWindow () { + return $('#annotatedSlideShowStep4Next'); } get findBackButtonHowItWorksWindow () { @@ -20,7 +43,7 @@ class HowItWorks extends Page { } get getStartedButton () { - return $('.cqTvJR>button'); + return $('#howItWorksGetStartedDesktopButton'); } get enterVoterEmailAddressTextBox () { @@ -116,12 +139,61 @@ class HowItWorks extends Page { await element.scrollIntoView() } + async clickHowItWorksLink () { + await this.howItWorksLink .click(); + } + async clickNextButtonFourTimes () { for (let i = 1; i <= 4; i++) { - await this.findNextButtonHowItWorksWindow.click(); + if (i == 1) { + await this.findFirstNextButtonHowItWorksWindow.click(); + }else if (i ==2){ + await this.findSecondNextButtonHowItWorksWindow.click(); + }else if (i ==3){ + await this.findThirdNextButtonHowItWorksWindow.click(); + }else { + await this.findFourthNextButtonHowItWorksWindow.click(); + } } } + async clickNextButton (i) { + if (i == 1) { + await this.findFirstNextButtonHowItWorksWindow.click(); + }else if (i ==2){ + await this.findSecondNextButtonHowItWorksWindow.click(); + }else if (i ==3){ + await this.findThirdNextButtonHowItWorksWindow.click(); + }else { + await this.findFourthNextButtonHowItWorksWindow.click(); + } + } + + + async checkDescriptionOfHowItWorksWindow (num) { + if (num === 1) { + return 'Follow topics that interest you. We will suggest endorsements based on your interests.'; + }else if (num === 2) { + return 'Learn from the people you trust. Their recommendations are highlighted on your ballot.'; + } 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.'; + } else if (num === 4) { + return 'WeVote is fast, mobile, and helps you decide on the go. Vote with confidence!'; + } 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.'; + } + } + + async checkBrokenImagesUsingResponseCode() { + const imageSrc = await this.howItWorksImage + const response = await fetch(imageSrc); + if (response.status == 200){ + console.log("Image loaded"); + } else{ + console.log('Image is not loaded'); + } + } + async clickBackButtonFourTimes () { for (let i = 1; i <= 4; i++) { await this.findBackButtonHowItWorksWindow.click(); diff --git a/tests/browserstack_automation/specs/HowItWorks.js b/tests/browserstack_automation/specs/HowItWorks.js index c17f4bc85..6b8944690 100644 --- a/tests/browserstack_automation/specs/HowItWorks.js +++ b/tests/browserstack_automation/specs/HowItWorks.js @@ -10,14 +10,13 @@ describe('HowItWorks', () => { it('verifyNextButton', async () => { await ReadyPage.load(); await driver.pause(waitTime); - await ReadyPage.clickHowItWorksLink(); + 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); if (i!= 5) { - const nextButton = await HowItWorks.findNextButtonHowItWorksWindow; - await HowItWorks.clickButton(nextButton) + await HowItWorks.clickNextButton(i) } } console.log("Next Button and titles of the page verified successfully") @@ -26,7 +25,7 @@ describe('HowItWorks', () => { it('verifyBackButton', async () => { await ReadyPage.load(); await driver.pause(waitTime); - await ReadyPage.clickHowItWorksLink(); + await HowItWorks.clickHowItWorksLink(); await driver.pause(waitTime); await HowItWorks.clickNextButtonFourTimes(); await HowItWorks.clickBackButtonFourTimes() @@ -37,7 +36,7 @@ describe('HowItWorks', () => { // HowItWorks_003 it('verifyGetStartedButton', async () => { await ReadyPage.load(); - await ReadyPage.clickHowItWorksLink(); + await HowItWorks.clickHowItWorksLink(); await driver.pause(waitTime); await HowItWorks.clickNextButtonFourTimes(); const getStarted = await HowItWorks.getStartedButton; @@ -49,7 +48,7 @@ describe('HowItWorks', () => { // HowItWorks_004 it('verifyCancelSigninwithEmail', async () => { await ReadyPage.load(); - await ReadyPage.clickHowItWorksLink(); + await HowItWorks.clickHowItWorksLink(); await driver.pause(waitTime); await HowItWorks.clickNextButtonFourTimes(); const getStarted = await HowItWorks.getStartedButton; @@ -64,7 +63,7 @@ describe('HowItWorks', () => { // HowItWorks_005 it('verifyCancelSigninWithMobile', async () => { await ReadyPage.load(); - await ReadyPage.clickHowItWorksLink(); + await HowItWorks.clickHowItWorksLink(); await driver.pause(waitTime); await HowItWorks.clickNextButtonFourTimes(); const getStarted = await HowItWorks.getStartedButton; @@ -79,7 +78,7 @@ describe('HowItWorks', () => { // HowItWorks_006 it('verifyCancelSigninWithApple', async () => { await ReadyPage.load(); - await ReadyPage.clickHowItWorksLink(); + await HowItWorks.clickHowItWorksLink(); await driver.pause(waitTime); await HowItWorks.clickNextButtonFourTimes(); const getStarted = await HowItWorks.getStartedButton; @@ -93,7 +92,7 @@ describe('HowItWorks', () => { // HowItWorks_007 it('verifyCancelSigninWithTwitter', async () => { await ReadyPage.load(); - await ReadyPage.clickHowItWorksLink(); + await HowItWorks.clickHowItWorksLink(); await driver.pause(waitTime); await HowItWorks.clickNextButtonFourTimes(); const getStarted = await HowItWorks.getStartedButton; @@ -111,7 +110,7 @@ describe('HowItWorks', () => { // HowItWorks_008 it('verifySigninUsingMobile', async () => { await ReadyPage.load(); - await ReadyPage.clickHowItWorksLink(); + await HowItWorks.clickHowItWorksLink(); await driver.pause(waitTime); await HowItWorks.clickNextButtonFourTimes(); const getStarted = await HowItWorks.getStartedButton; @@ -129,11 +128,52 @@ describe('HowItWorks', () => { const profileAvatar = await HowItWorks.enterProfileAvatar; await HowItWorks.clickButton(profileAvatar) console.log("User was able to successfully signIn using mobile") + }); + // HowItWorks_009 + it('verifySigninUsingEmail', async () => { + await ReadyPage.load(); + await HowItWorks.clickHowItWorksLink(); + await driver.pause(waitTime); + await HowItWorks.clickNextButtonFourTimes(); + const getStarted = await HowItWorks.getStartedButton; + await HowItWorks.clickButton(getStarted) + 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++) { + 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 Email") + }); + // HowItWorks_012 + it('verifyImagesAndContent', async () => { + await ReadyPage.load(); + await driver.pause(waitTime); + await HowItWorks.clickHowItWorksLink(); //Charanya + 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.checkBrokenImagesUsingResponseCode() + if (i!= 5) { + await HowItWorks.clickNextButton(i) + } + await driver.pause(waitTime); + } + console.log("Images and contents of the page verified successfully") }); //HowItWorks_013 it('verifyInvalidMobileNumber' , async () =>{ await ReadyPage.load(); - await ReadyPage.clickHowItWorksLink(); + await HowItWorks.clickHowItWorksLink(); await driver.pause(waitTime); await HowItWorks.clickNextButtonFourTimes(); const getStarted = await HowItWorks.getStartedButton; @@ -147,7 +187,7 @@ describe('HowItWorks', () => { //HowItWorks_014 it('VerifyInvalidEmailAddress' , async () =>{ await ReadyPage.load(); - await ReadyPage.clickHowItWorksLink(); + await HowItWorks.clickHowItWorksLink(); await driver.pause(waitTime); await HowItWorks.clickNextButtonFourTimes(); const getStarted = await HowItWorks.getStartedButton; @@ -161,7 +201,7 @@ describe('HowItWorks', () => { // HowItWorks_015 it('verifyDeleteUnverifiedPhoneNumbers', async () => { await ReadyPage.load(); - await ReadyPage.clickHowItWorksLink(); + await HowItWorks.clickHowItWorksLink(); await driver.pause(waitTime); await HowItWorks.clickNextButtonFourTimes(); const getStarted = await HowItWorks.getStartedButton; @@ -181,7 +221,7 @@ describe('HowItWorks', () => { // HowItWorks_016 it('verifyDeleteUnverifiedEmailAddress', async () => { await ReadyPage.load(); - await ReadyPage.clickHowItWorksLink(); + await HowItWorks.clickHowItWorksLink(); await driver.pause(waitTime); await HowItWorks.clickNextButtonFourTimes(); const getStarted = await HowItWorks.getStartedButton;