Skip to content

Commit

Permalink
WV-421 Implemented HowItWorks_009 - HowItWorks_012 [Web] test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
charanya-QA committed Dec 3, 2024
1 parent cac9299 commit 49ae421
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 18 deletions.
80 changes: 76 additions & 4 deletions tests/browserstack_automation/page_objects/howitworks.js
Original file line number Diff line number Diff line change
@@ -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 () {
Expand All @@ -20,7 +43,7 @@ class HowItWorks extends Page {
}

get getStartedButton () {
return $('.cqTvJR>button');
return $('#howItWorksGetStartedDesktopButton');
}

get enterVoterEmailAddressTextBox () {
Expand Down Expand Up @@ -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();
Expand Down
68 changes: 54 additions & 14 deletions tests/browserstack_automation/specs/HowItWorks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 49ae421

Please sign in to comment.