Skip to content

Commit

Permalink
Merge pull request wevote#3887 from fdiazq/develop
Browse files Browse the repository at this point in the history
Updated existing testcases for FAQPage, ReadyPage, and PrivacyPage TeamReview
  • Loading branch information
DaleMcGrew authored Apr 17, 2024
2 parents ec07d7b + 8b930b2 commit f01d9fd
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 94 deletions.
4 changes: 2 additions & 2 deletions tests/browserstack_automation/config/wdio.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports.config = {
],
],
specs: [
'../specs/*.js',
'../specs/ReadyPage.js',
],
capabilities,
commonCapabilities: {
Expand All @@ -49,7 +49,7 @@ module.exports.config = {
// Oakland, CA, USA
gpsLocation: '37.804363,-122.271111',
maskCommands: 'setValues, getValues, setCookies, getCookies',
// video: 'false',
video: 'true',
},
},
maxInstances: 1,
Expand Down
56 changes: 28 additions & 28 deletions tests/browserstack_automation/page_objects/faq.page.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { $, $$ } from '@wdio/globals';
import { $, $$, driver } from '@wdio/globals';
import Page from './page';
import { driver, expect } from '@wdio/globals';

class FAQPage extends Page {
constructor () {
Expand Down Expand Up @@ -30,14 +29,14 @@ class FAQPage extends Page {
}

get getWeVoteElementFromInstagram () {
return $('//h2[contains(text(), "wevote")]')
return $('//h2[contains(text(), "wevote")]');
}

get getEmailIconElement () {
return $('#eepurl');
}

get getGitHubIconElement() {
get getGitHubIconElement () {
return $$('//a[@href = "https://github.com/WeVote"]');
}

Expand All @@ -49,17 +48,17 @@ class FAQPage extends Page {
return $$('//a[@id = "helpSiteValues"]');
}

async clickValueLink() {
async clickValueLink () {
const selectorToGetValueElements = '//a[@id = "helpSiteValues"]';
let arrOfElements = [];
for(let i = 1; i <= await $$(selectorToGetValueElements).length; i++) {
await $(`(${selectorToGetValueElements})[${i}]`).click();
const windowHandles = await driver.getWindowHandles();
await driver.switchToWindow(windowHandles[1]);
let textFromElement = await driver.getTitle();
await arrOfElements.push(textFromElement);
await driver.closeWindow();
await driver.switchWindow('https://quality.wevote.us/more/faq');
const arrOfElements = [];
for (let i = 1; i <= $$(selectorToGetValueElements).length; i++) {
$(`(${selectorToGetValueElements})[${i}]`).click();
const windowHandles = driver.getWindowHandles();
driver.switchToWindow(windowHandles[1]);
const textFromElement = driver.getTitle();
arrOfElements.push(textFromElement);
driver.closeWindow();
driver.switchWindow('https://quality.wevote.us/more/faq');
}
return arrOfElements;
}
Expand All @@ -76,15 +75,15 @@ class FAQPage extends Page {
return $$('//a[@href = "https://wevote.applytojob.com/apply"]');
}

async clickVolunteerOpeningsLinks() {
async clickVolunteerOpeningsLinks () {
const selectorToGetElements = '//a[@href = "https://wevote.applytojob.com/apply"]';
let arrOfElements = [];
for(let i = 1; i <= await $$(selectorToGetElements).length; i++) {
await $(`(${selectorToGetElements})[${i}]`).click();
await driver.switchWindow('https://wevote.applytojob.com/apply');
let textFromElement = await driver.getTitle();
const arrOfElements = [];
for (let i = 1; i <= $$(selectorToGetElements).length; i++) {
$(`(${selectorToGetElements})[${i}]`).click();
driver.switchWindow('https://wevote.applytojob.com/apply');
const textFromElement = driver.getTitle();
arrOfElements.push(textFromElement);
await driver.switchWindow('https://quality.wevote.us/more/faq');
driver.switchWindow('https://quality.wevote.us/more/faq');
}
return arrOfElements;
}
Expand Down Expand Up @@ -117,18 +116,19 @@ class FAQPage extends Page {
return $('//a[contains(text(), "get started!")]');
}

async clickGitHubIconAndLinks() {
async clickGitHubIconAndLinks () {
const selectorToGetElements = '//a[@href = "https://github.com/WeVote"]';
let arrOfElements = [];
for(let i = 1; i <= await $$(selectorToGetElements).length; i++) {
await $(`(${selectorToGetElements})[${i}]`).click();
await driver.switchWindow('https://github.com/WeVote');
let textFromElement = await driver.getTitle();
const arrOfElements = [];
for (let i = 1; i <= $$(selectorToGetElements).length; i++) {
$(`(${selectorToGetElements})[${i}]`).click();
driver.switchWindow('https://github.com/WeVote');
const textFromElement = driver.getTitle();
arrOfElements.push(textFromElement);
await driver.switchWindow('https://quality.wevote.us/more/faq');
driver.switchWindow('https://quality.wevote.us/more/faq');
}
return arrOfElements;
}
}

export default new FAQPage();
// const { describe } = require('mocha');
16 changes: 8 additions & 8 deletions tests/browserstack_automation/page_objects/privacy.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ class PrivacyPage extends Page {
return $$('//a[text() = "info@WeVote.US"]');
}

get deleteYourAccountButton () {
get deleteYourAccountButton () {
return $('.DeleteYourAccountButtonInnerWrapper-sc-qu6md9-2');
}
}

get cancelOfDeleteYourAccountButton () {
get cancelOfDeleteYourAccountButton () {
return $('.DeleteYourAccountButtonInnerCancelWrapper-sc-qu6md9-1');
}
}

async getTextFromEmailLinks() {
async getTextFromEmailLinks () {
const selectorToGetElements = '//a[text() = "info@WeVote.US"]';
let arrOfElements = [];
for(let i = 1; i <= await $$(selectorToGetElements).length; i++) {
let textFromElement = await $(`(${selectorToGetElements})[${i}]`).getText();
const arrOfElements = [];
for (let i = 1; i <= $$(selectorToGetElements).length; i++) {
const textFromElement = $(`(${selectorToGetElements})[${i}]`).getText();
arrOfElements.push(textFromElement);
}

Expand Down
69 changes: 36 additions & 33 deletions tests/browserstack_automation/page_objects/ready.page.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { $, $$ } from '@wdio/globals';
import { $, $$, driver } from '@wdio/globals';
import Page from './page';
import { driver, expect } from '@wdio/globals';

class ReadyPage extends Page {
constructor () {
Expand All @@ -12,7 +11,7 @@ class ReadyPage extends Page {
}

get electionCountDownTitle () {
return $('#electionCountDownTitle');
return $('//*[contains(@id, "electionCountDownTitle")]');
}

get ballotTitle () {
Expand Down Expand Up @@ -40,15 +39,15 @@ class ReadyPage extends Page {
}

get toggleIntroductionButton () {
return $('//*[contains(@id, "showMoreReadyIntroductionCompressed")]');
return $('//*[contains(@id, "toggleContentButton-showMoreReadyIntroductionCompressed")]');
}

get introductionStepText () {
return $$('//div[contains(@id, "readyIntroductionStepText")]');
}

get toggleFinePrintButton () {
return $('//*[contains(@id, "showMoreReadyFinePrintCompressed")]');
return $('//*[contains(@id, "toggleContentButton-showMoreReadyFinePrintCompressed")]');
}

get finePrintStepText () {
Expand Down Expand Up @@ -88,7 +87,7 @@ class ReadyPage extends Page {
}

get findPrivacyLink () {
return $('#footerLinkPrivacy');
return $('#footerLinkPrivacy');
}

get findNextButtonHowItWorksWindow () {
Expand Down Expand Up @@ -160,7 +159,7 @@ class ReadyPage extends Page {
}

async waitAboutLinkAndClick () {
await driver.pause(2000);
await driver.pause(5000);
await this.getAboutLinkElement.click();
}

Expand All @@ -176,6 +175,10 @@ class ReadyPage extends Page {
await this.ballotTitle.findAndClick();
}

async openBallotcount () {
await this.electionCountDownTitle.findAndClick();
}

async updateBallotAddress (ballotAddress) {
await this.ballotAddress.findAndClick();
await this.ballotAddressInput.setValue(ballotAddress);
Expand Down Expand Up @@ -214,42 +217,42 @@ class ReadyPage extends Page {

async clickNextButtonHowItWorksWindow () {
let num = Math.floor(Math.random() * 5);
if (num == 0) {
num = num + 1;
if (num === 0) {
num += 1;
}

for (let i = 1; i <= num; i++) {
await this.findNextButtonHowItWorksWindow.click();
this.findNextButtonHowItWorksWindow.click();
}
return num;
}

async checkTitleOfHowItWorksWindow() {
let num = await this.clickNextButtonHowItWorksWindow();
if(num == 1) {
return "2. Follow organizations and people you trust";
} else if (num == 2) {
return "3. See who endorsed each choice on your ballot";
} else if (num == 3) {
return "4. Complete your ballot with confidence";
} else {
return "5. Share with friends who could use a guide"
}
async checkTitleOfHowItWorksWindow () {
const num = await this.clickNextButtonHowItWorksWindow();
if (num === 1) {
return '2. Follow organizations and people you trust';
} else if (num === 2) {
return '3. See who endorsed each choice on your ballot';
} else if (num === 3) {
return '4. Complete your ballot with confidence';
} else {
return '5. Share with friends who could use a guide';
}
}

async getTitleOfHowItWorksWindowAfterBackButton() {
let num = await this.clickNextButtonHowItWorksWindow();
async getTitleOfHowItWorksWindowAfterBackButton () {
const num = await this.clickNextButtonHowItWorksWindow();
await this.findBackButtonHowItWorksWindow.click();

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 {
return "4. Complete your ballot with confidence";
}
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 {
return '4. Complete your ballot with confidence';
}
}

async clickGetStartedButton () {
Expand All @@ -258,7 +261,7 @@ class ReadyPage extends Page {

async clickNextButtonFourTimes () {
for (let i = 1; i <= 4; i++) {
await this.findNextButtonHowItWorksWindow.click();
this.findNextButtonHowItWorksWindow.click();
}
}
}
Expand Down
25 changes: 15 additions & 10 deletions tests/browserstack_automation/specs/FAQPage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { driver, expect } from '@wdio/globals';
import ReadyPage from '../page_objects/ready.page';
import FAQPage from '../page_objects/faq.page';

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

describe('FAQPage', () => {
// FAQ_001
Expand All @@ -25,7 +27,8 @@ describe('FAQPage', () => {
await ReadyPage.load();
await ReadyPage.waitAboutLinkAndClick();
await FAQPage.getEmailIconElement.click();
await driver.switchWindow('https://us8.list-manage.com/subscribe?u=29bec99e46ac46abe32781925&id=5e052cb629');
await driver.pause(5000);
await driver.switchWindow('https://wevote.us8.list-manage.com/subscribe?u=29bec99e46ac46abe32781925&id=5e052cb629');
await expect(driver).toHaveTitle('We Vote');
});

Expand All @@ -34,9 +37,9 @@ describe('FAQPage', () => {
await ReadyPage.load();
await ReadyPage.waitAboutLinkAndClick();
await expect(FAQPage.getGitHubIconElement).toBeElementsArrayOfSize(3);
let actualResultArray = await FAQPage.clickGitHubIconAndLinks();
const actualResultArray = await FAQPage.clickGitHubIconAndLinks();
for (let i = 0; i < actualResultArray.length; i++) {
let actualResult = await actualResultArray[i];
const actualResult = actualResultArray[i];
assert.equal(actualResult, 'We Vote · GitHub');
}
});
Expand All @@ -55,7 +58,7 @@ describe('FAQPage', () => {
await ReadyPage.load();
await ReadyPage.waitAboutLinkAndClick();
await FAQPage.getWeVoteEducationWebsiteElement.click();
driver.switchWindow('https://www.wevoteeducation.org/');
await driver.switchWindow('https://www.wevoteeducation.org/');
await expect(driver).toHaveTitle('We Vote Education Fund');
});

Expand All @@ -73,10 +76,10 @@ describe('FAQPage', () => {
await ReadyPage.load();
await ReadyPage.waitAboutLinkAndClick();
await expect(FAQPage.getWeVoteVolunteerElements).toBeElementsArrayOfSize(2);
let actualResultArray = await FAQPage.clickVolunteerOpeningsLinks();
const actualResultArray = await FAQPage.clickVolunteerOpeningsLinks();
for (let i = 0; i < actualResultArray.length; i++) {
let actualResult = await actualResultArray[i];
assert.equal(actualResult, 'We Vote - Career Page');
const actualResult = actualResultArray[i];
assert.equal(actualResult, 'WeVote - Career Page');
}
});

Expand All @@ -86,7 +89,7 @@ describe('FAQPage', () => {
await ReadyPage.waitAboutLinkAndClick();
await FAQPage.getAboutPageTitleElement.click();
driver.switchWindow('https://wevote.us/more/about');
await expect(driver).toHaveTitle('About We Vote');
await expect(driver).toHaveTitle('About WeVote');
});

// FAQ_013
Expand All @@ -103,6 +106,7 @@ describe('FAQPage', () => {
await ReadyPage.load();
await ReadyPage.waitAboutLinkAndClick();
await FAQPage.getWeVoteIPhoneLinkElement.click();
await driver.pause(5000);
driver.switchWindow('https://apps.apple.com/us/app/we-vote-ballot-guide-wevote/id1347335726');
await expect(driver).toHaveTitle('We Vote Ballot Guide, @WeVote on the App Store');
});
Expand All @@ -112,6 +116,7 @@ describe('FAQPage', () => {
await ReadyPage.load();
await ReadyPage.waitAboutLinkAndClick();
await FAQPage.getWeVoteAndroidLinkElement.findAndClick();
await driver.pause(5000);
await driver.switchWindow('https://play.google.com/store/apps/details?id=org.wevote.cordova&hl=en_US');
await expect(driver).toHaveTitle('We Vote Ballot Guide, @WeVote - Apps on Google Play');
});
Expand All @@ -121,15 +126,15 @@ describe('FAQPage', () => {
await ReadyPage.load();
await ReadyPage.waitAboutLinkAndClick();
await FAQPage.getPleaseDonateElement.click();
await expect(driver).toHaveTitle('Donate - We Vote');
await expect(driver).toHaveTitle('Donate - WeVote');
});

// FAQ_017
it('verifyLetsGetStartedLinkRedirected', async () => {
await ReadyPage.load();
await ReadyPage.waitAboutLinkAndClick();
await FAQPage.getLetsGetStartedElement.click();
await expect(driver).toHaveTitle('Ready to Vote? - We Vote');
await expect(driver).toHaveTitle('Ready to Vote? - WeVote');
await expect(ReadyPage.getFollowPopularTopicsElement).toHaveText('Follow Popular Topics');
});
});
Loading

0 comments on commit f01d9fd

Please sign in to comment.