Skip to content

Commit

Permalink
Added TopNavigation test cases and fix to readypage
Browse files Browse the repository at this point in the history
  • Loading branch information
fdiazq committed May 6, 2024
1 parent 5b4d1ac commit ad1856e
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 27 deletions.
1 change: 1 addition & 0 deletions tests/browserstack_automation/config/wdio.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module.exports.config = {
'../specs/PrivacyPage.js',
'../specs/ReadyPage.js',
'../specs/TermsPage.js',
'../specs/TopNavigation.js',
],
capabilities,
commonCapabilities: {
Expand Down
8 changes: 8 additions & 0 deletions tests/browserstack_automation/page_objects/ready.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class ReadyPage extends Page {
return $$('//*[contains(@id, "readyIntroductionStepText")]');
}

get getIntroText () {
return $('.StepText-sc-lvvjo6-11 kIDCci');
}

get toggleFinePrintButton () {
return $('#toggleContentButton-showMoreReadyFinePrintCompressed');
}
Expand Down Expand Up @@ -203,6 +207,10 @@ class ReadyPage extends Page {
await this.toggleIntroductionButton.findAndClick();
}

async toggleIntroStepText () {
await this.introductionStepText.findAndClick();
}

async toggleFinePrint () {
await this.toggleFinePrintButton.findAndClick();
}
Expand Down
49 changes: 49 additions & 0 deletions tests/browserstack_automation/page_objects/topnavigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { $ } from '@wdio/globals';
import Page from './page';



class TopNavigation extends Page {
get getBallotLinkLocator () {
return $('[href = "/ballot"]');
}

get getBallotTabLocator () {
return $('#ballotTabHeaderBar');
}

get getCandidatesTabLocator () {
return $('#candidatesTabHeaderBar');
}

get getDonateTabLocator () {
return $('#donateTabHeaderBar');
}

get getSquadsTabLocator () {
return $('#squadsTabHeaderBar');
}

get getWeVoteLogoLocator () {
return $('#logoHeaderBar');
}

async toggleCandidatesTab () {
await this.getCandidatesTabLocator.findAndClick();
}

async toggleDonateTab () {
await this.getDonateTabLocator.findAndClick();
}

async toggleLogoBar () {
await this.getWeVoteLogoLocator.findAndClick();
}

async toggleSquadsTab () {
await this.getSquadsTabLocator.findAndClick();
}
}

export default new TopNavigation();

1 change: 1 addition & 0 deletions tests/browserstack_automation/specs/PrivacyPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('Privacy Page', () => {
// Privacy_002
it('verifyCampaignsWeVoteUSLinkRedirect', async () => {
await ReadyPage.load();
await driver.waitUntil(async () => (ReadyPage.findPrivacyLink.isClickable()));
await ReadyPage.findPrivacyLink.click();
await PrivacyPage.campaignsWeVoteUSLink.findAndClick();
await driver.switchWindow('https://campaigns.wevote.us/');
Expand Down
32 changes: 5 additions & 27 deletions tests/browserstack_automation/specs/ReadyPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('ReadyPage', () => {
it('verifyElectionCountDownRedirect', async () => {
await ReadyPage.load();
await driver.pause(9000);
await driver.waitUntil(async () => (ReadyPage.electionCountDownTitle.isClickable()));
await ReadyPage.electionCountDownTitle.click();
await driver.waitUntil(async () => {
// Add condition to check for the expected URL
Expand Down Expand Up @@ -63,41 +64,18 @@ describe('ReadyPage', () => {
it('toggleIntroduction', async () => {
await ReadyPage.load();
await expect(ReadyPage.introductionStepText).not.toBeDisplayed();
await driver.pause(9000);
await driver.waitUntil(async () => (ReadyPage.toggleIntroductionButton.isClickable()));
await ReadyPage.toggleIntroductionButton.click();
// await ReadyPage.toggleIntroduction();
await driver.waitUntil(async () => {
// Add condition to check for the expected URL
const currentUrl = await driver.getUrl();
console.log(currentUrl);
function checkIntroStepTextSize () {
return ReadyPage.introductionStepText.toBeElementsArrayOfSize(3);
}
return checkIntroStepTextSize();
}, {
timeout: 10000,
timeoutMsg: 'Expected steptext to be 3 not found, timeout after 10000ms',
});
await expect(ReadyPage.introductionStepText).toBeElementsArrayOfSize(3);
});

// Ready_007
it('toggleFinePrint', async () => {
await ReadyPage.load();
await expect(ReadyPage.finePrintStepText).not.toBeDisplayed();
await driver.pause(9000);
await driver.waitUntil(async () => (ReadyPage.toggleIntroductionButton.isClickable()));
await ReadyPage.toggleFinePrintButton.click();
await driver.waitUntil(async () => {
// Add condition to check for the expected URL
const currentUrl = await driver.getUrl();
console.log(currentUrl);
function checkIntroStepTextSize () {
return ReadyPage.introductionStepText.toBeElementsArrayOfSize(4);
}
return checkIntroStepTextSize();
}, {
timeout: 10000,
timeoutMsg: 'Expected steptext to be 4 not found, timeout after 10000ms',
});
await expect(ReadyPage.finePrintStepText).toBeElementsArrayOfSize(4);
});

// Ready_008
Expand Down
142 changes: 142 additions & 0 deletions tests/browserstack_automation/specs/TopNavigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import { driver, expect } from '@wdio/globals';
import ReadyPage from '../page_objects/ready.page';
import TopNavigation from '../page_objects/topnavigation';

const { describe, it } = require('mocha');

describe('TopNavigation', () => {
// TopNavigation_001
it('openWeVoteHomeLogo', async () => {
await ReadyPage.load();
await driver.pause(9000);
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 driver.switchWindow('Ballot - WeVote');
await TopNavigation.toggleLogoBar();
await driver.waitUntil(async () => {
// Add condition to check for the expected URL
const currentUrl = await driver.getUrl();
console.log(currentUrl);
return currentUrl.includes('ready');
}, {
timeout: 10000,
timeoutMsg: 'Expected URL to contain "ready" not found, timeout after 10000ms',
});
await driver.switchWindow('Ready to Vote? - WeVote');
await expect(driver).toHaveUrl(expect.stringContaining('ready'));
});

// TopNavigation_002
it('openBallotTab', async () => {
await ReadyPage.load();
await driver.pause(9000);
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 driver.switchWindow('Ballot - WeVote');
await expect(driver).not.toHaveUrl(expect.stringContaining('ready'));
});


// TopNavigation_003
// it('signIn', async () => {
// await ReadyPage.load();
// await expect(ReadyPage.avatar).not.toExist();
// await ReadyPage.signIn();
// await expect(ReadyPage.avatar).toBeDisplayed();
// });

// Friends page accessible after sign in
// // TopNavigation_004
// it('openFriendsTab', async () => {
// await ReadyPage.load();
// });

// Discuss page tab not in header bar
// // TopNavigation_005
// it('openDiscussTab', async () => {
// await ReadyPage.load();
// });

// HowitWorks tab not in header bar
// // TopNavigation_006
// it('openHowItWorksTab', async () => {
// await ReadyPage.load();
// });

// TopNavigation_007
it('openDonateTab', async () => {
await ReadyPage.load();
await driver.pause(9000);
await TopNavigation.toggleDonateTab();
await driver.waitUntil(async () => {
// Add condition to check for the expected URL
const currentUrl = await driver.getUrl();
console.log(currentUrl);
return currentUrl.includes('donate');
}, {
timeout: 10000,
timeoutMsg: 'Expected URL to contain "donate" not found, timeout after 10000ms',
});
await driver.switchWindow('Donate - WeVote');
await expect(driver).not.toHaveUrl(expect.stringContaining('ready'));
});

// Feature doesn't exist
// // TopNavigation_008
// it('BallotTab', async () => {
// await ReadyPage.load();
// await driver.pause(9000);
// });

// TopNavigation_009
it('openCandidatesTab', async () => {
await ReadyPage.load();
await driver.pause(9000);
await TopNavigation.toggleCandidatesTab();
await driver.waitUntil(async () => {
// Add condition to check for the expected URL
const currentUrl = await driver.getUrl();
console.log(currentUrl);
return currentUrl.includes('candidates');
}, {
timeout: 10000,
timeoutMsg: 'Expected URL to contain "candidates" not found, timeout after 10000ms',
});
// await driver.switchWindow('Donate - WeVote');
await expect(driver).not.toHaveUrl(expect.stringContaining('ready'));
});

// TopNavigation_0010
it('openSquadsTab', async () => {
await ReadyPage.load();
await driver.pause(9000);
await TopNavigation.toggleSquadsTab();
await driver.waitUntil(async () => {
// Add condition to check for the expected URL
const currentUrl = await driver.getUrl();
console.log(currentUrl);
return currentUrl.includes('squads');
}, {
timeout: 10000,
timeoutMsg: 'Expected URL to contain "squads" not found, timeout after 10000ms',
});
await driver.switchWindow('Democracy Squads - WeVote');
await expect(driver).not.toHaveUrl(expect.stringContaining('ready'));
});
});

0 comments on commit ad1856e

Please sign in to comment.