From 6f0264853869762be7668176b5f36e6e6d5eed4a Mon Sep 17 00:00:00 2001 From: fdiazq~ Date: Mon, 15 Apr 2024 21:28:18 -0700 Subject: [PATCH] Updated existing testcases for FAQPage, ReadyPage, and PrivacyPage \ --- .../config/wdio.config.js | 4 +- .../page_objects/faq.page.js | 56 +++++++-------- .../page_objects/privacy.page.js | 16 ++--- .../page_objects/ready.page.js | 69 ++++++++++--------- .../browserstack_automation/specs/FAQPage.js | 25 ++++--- .../specs/PrivacyPage.js | 19 +++-- .../specs/ReadyPage.js | 13 +++- .../specs/TermsPage.js | 8 ++- 8 files changed, 116 insertions(+), 94 deletions(-) diff --git a/tests/browserstack_automation/config/wdio.config.js b/tests/browserstack_automation/config/wdio.config.js index c2a34b0f6..9a26f2bd4 100644 --- a/tests/browserstack_automation/config/wdio.config.js +++ b/tests/browserstack_automation/config/wdio.config.js @@ -36,7 +36,7 @@ module.exports.config = { ], ], specs: [ - '../specs/*.js', + '../specs/ReadyPage.js', ], capabilities, commonCapabilities: { @@ -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, diff --git a/tests/browserstack_automation/page_objects/faq.page.js b/tests/browserstack_automation/page_objects/faq.page.js index 13f507578..1bb147020 100644 --- a/tests/browserstack_automation/page_objects/faq.page.js +++ b/tests/browserstack_automation/page_objects/faq.page.js @@ -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 () { @@ -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"]'); } @@ -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; } @@ -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; } @@ -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'); diff --git a/tests/browserstack_automation/page_objects/privacy.page.js b/tests/browserstack_automation/page_objects/privacy.page.js index 6ad95e2f7..ac4135257 100644 --- a/tests/browserstack_automation/page_objects/privacy.page.js +++ b/tests/browserstack_automation/page_objects/privacy.page.js @@ -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); } diff --git a/tests/browserstack_automation/page_objects/ready.page.js b/tests/browserstack_automation/page_objects/ready.page.js index 9336572da..9f0dfbd61 100644 --- a/tests/browserstack_automation/page_objects/ready.page.js +++ b/tests/browserstack_automation/page_objects/ready.page.js @@ -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 () { @@ -12,7 +11,7 @@ class ReadyPage extends Page { } get electionCountDownTitle () { - return $('#electionCountDownTitle'); + return $('//*[contains(@id, "electionCountDownTitle")]'); } get ballotTitle () { @@ -40,7 +39,7 @@ class ReadyPage extends Page { } get toggleIntroductionButton () { - return $('//*[contains(@id, "showMoreReadyIntroductionCompressed")]'); + return $('//*[contains(@id, "toggleContentButton-showMoreReadyIntroductionCompressed")]'); } get introductionStepText () { @@ -48,7 +47,7 @@ class ReadyPage extends Page { } get toggleFinePrintButton () { - return $('//*[contains(@id, "showMoreReadyFinePrintCompressed")]'); + return $('//*[contains(@id, "toggleContentButton-showMoreReadyFinePrintCompressed")]'); } get finePrintStepText () { @@ -88,7 +87,7 @@ class ReadyPage extends Page { } get findPrivacyLink () { - return $('#footerLinkPrivacy'); + return $('#footerLinkPrivacy'); } get findNextButtonHowItWorksWindow () { @@ -160,7 +159,7 @@ class ReadyPage extends Page { } async waitAboutLinkAndClick () { - await driver.pause(2000); + await driver.pause(5000); await this.getAboutLinkElement.click(); } @@ -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); @@ -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 () { @@ -258,7 +261,7 @@ class ReadyPage extends Page { async clickNextButtonFourTimes () { for (let i = 1; i <= 4; i++) { - await this.findNextButtonHowItWorksWindow.click(); + this.findNextButtonHowItWorksWindow.click(); } } } diff --git a/tests/browserstack_automation/specs/FAQPage.js b/tests/browserstack_automation/specs/FAQPage.js index 5e0495025..91e653ddf 100644 --- a/tests/browserstack_automation/specs/FAQPage.js +++ b/tests/browserstack_automation/specs/FAQPage.js @@ -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 @@ -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'); }); @@ -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'); } }); @@ -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'); }); @@ -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'); } }); @@ -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 @@ -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'); }); @@ -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'); }); @@ -121,7 +126,7 @@ 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 @@ -129,7 +134,7 @@ describe('FAQPage', () => { 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'); }); }); diff --git a/tests/browserstack_automation/specs/PrivacyPage.js b/tests/browserstack_automation/specs/PrivacyPage.js index 27921f35f..e9d370fe0 100644 --- a/tests/browserstack_automation/specs/PrivacyPage.js +++ b/tests/browserstack_automation/specs/PrivacyPage.js @@ -1,10 +1,11 @@ import { driver, expect } from '@wdio/globals'; import ReadyPage from '../page_objects/ready.page'; import PrivacyPage from '../page_objects/privacy.page'; + const assert = require('assert'); +const { describe, it } = require('mocha'); describe('Privacy Page', () => { - // Privacy_001 it('verifyWeVoteUSLinkRedirect', async () => { await ReadyPage.load(); @@ -12,7 +13,7 @@ describe('Privacy Page', () => { await PrivacyPage.weVoteUSLink.click(); await driver.switchWindow('https://wevote.us/'); await expect(driver).toHaveUrl('https://wevote.us/'); - await expect(driver).toHaveTitle('Ready to Vote? - We Vote'); + await expect(driver).toHaveTitle('Ready to Vote? - WeVote'); }); // Privacy_002 @@ -40,7 +41,7 @@ describe('Privacy Page', () => { await PrivacyPage.deleteYourAccountLink.click(); await PrivacyPage.deleteYourAccountButton.click(); await driver.pause(3000); - await expect(driver).toHaveTitle('Ready to Vote? - We Vote'); + await expect(driver).toHaveTitle('Privacy Policy - WeVote'); }); // Privacy_005_2 @@ -75,8 +76,12 @@ describe('Privacy Page', () => { it('verifyOpenReplayPrivacyLink', async () => { await ReadyPage.load(); await ReadyPage.findPrivacyLink.click(); + await driver.pause(5000); await PrivacyPage.openReplayPrivacyLink.click(); - await driver.switchWindow("https://openreplay.com/privacy.html"); + // await driver.pause(5000); + await driver.switchWindow('https://openreplay.com/legal/privacy.html'); + await driver.pause(5000); + // await expect(driver).toHaveUrl('https://openreplay.com/privacy.html'); await expect(driver).toHaveTitle('Privacy | OpenReplay'); }); @@ -84,11 +89,11 @@ describe('Privacy Page', () => { it('verifyEmailLinks', async () => { await ReadyPage.load(); await ReadyPage.findPrivacyLink.click(); - + await driver.pause(3000); await expect(PrivacyPage.emailLink).toBeElementsArrayOfSize(2); - let actualResultArray = await PrivacyPage.getTextFromEmailLinks(); + const actualResultArray = await PrivacyPage.getTextFromEmailLinks(); for (let i = 0; i < actualResultArray.length; i++) { - let actualResult = await actualResultArray[i]; + const actualResult = actualResultArray[i]; assert.equal(actualResult, 'info@WeVote.US'); } }); diff --git a/tests/browserstack_automation/specs/ReadyPage.js b/tests/browserstack_automation/specs/ReadyPage.js index a9dee533c..2ed61b1d4 100644 --- a/tests/browserstack_automation/specs/ReadyPage.js +++ b/tests/browserstack_automation/specs/ReadyPage.js @@ -12,7 +12,9 @@ describe('ReadyPage', () => { // Ready_001 it('verifyElectionCountDownRedirect', async () => { await ReadyPage.load(); + await driver.pause(9000); await ReadyPage.electionCountDownTitle.findAndClick(); + await driver.pause(9000); await expect(driver).not.toHaveUrl(expect.stringContaining('ready')); }); @@ -51,7 +53,9 @@ describe('ReadyPage', () => { it('toggleIntroduction', async () => { await ReadyPage.load(); await expect(ReadyPage.introductionStepText).not.toBeDisplayed(); + await driver.pause(9000); await ReadyPage.toggleIntroduction(); + await driver.pause(9000); await expect(ReadyPage.introductionStepText).toBeElementsArrayOfSize(3); }); @@ -59,7 +63,10 @@ describe('ReadyPage', () => { it('toggleFinePrint', async () => { await ReadyPage.load(); await expect(ReadyPage.finePrintStepText).not.toBeDisplayed(); + await driver.pause(9000); + await ReadyPage.toggleFinePrint(); + await driver.pause(9000); await expect(ReadyPage.finePrintStepText).toBeElementsArrayOfSize(4); }); @@ -92,7 +99,7 @@ describe('ReadyPage', () => { await ReadyPage.clickHowItWorksLink(); await ReadyPage.howItWorksTitle.isDisplayed(); await ReadyPage.closeHowItWorksModalWindow(); - await expect(ReadyPage.elementHowItWorksWindow).not.toBeDisplayed() + await expect(ReadyPage.elementHowItWorksWindow).not.toBeDisplayed(); }); // Ready_012 @@ -100,7 +107,7 @@ describe('ReadyPage', () => { await ReadyPage.load(); await ReadyPage.clickHowItWorksLink(); - let expectedResult = await ReadyPage.checkTitleOfHowItWorksWindow(); + const expectedResult = await ReadyPage.checkTitleOfHowItWorksWindow(); await expect(ReadyPage.howItWorksTitle).toHaveText(expectedResult); }); @@ -118,7 +125,7 @@ describe('ReadyPage', () => { await ReadyPage.load(); await ReadyPage.clickHowItWorksLink(); - let expectedResult = await ReadyPage.getTitleOfHowItWorksWindowAfterBackButton(); + const expectedResult = await ReadyPage.getTitleOfHowItWorksWindowAfterBackButton(); await expect(ReadyPage.howItWorksTitle).toHaveText(expectedResult); }); diff --git a/tests/browserstack_automation/specs/TermsPage.js b/tests/browserstack_automation/specs/TermsPage.js index 92749552c..6799abf61 100644 --- a/tests/browserstack_automation/specs/TermsPage.js +++ b/tests/browserstack_automation/specs/TermsPage.js @@ -3,17 +3,19 @@ import ReadyPage from '../page_objects/ready.page'; import PrivacyPage from '../page_objects/privacy.page'; import TermsPage from '../page_objects/terms.page'; +const { describe, it } = require('mocha'); + describe('TermsPage', () => { // Terms_001 - it.only ('verifyGitHubLinkRedirected', async () => { + it.only('verifyGitHubLinkRedirected', async () => { await ReadyPage.load(); - await ReadyPage.getTermsLinkElement.findAndClick();; + await ReadyPage.getTermsLinkElement.findAndClick(); await TermsPage.getGitHubLink.click(); driver.switchWindow('https://github.com/WeVote'); await expect(driver).toHaveTitle('We Vote · GitHub'); }); - //Terms_002 + // Terms_002 it('verifyPrivacyPolicyLinkRedirected', async () => { await ReadyPage.load(); await ReadyPage.getTermsLinkElement.findAndClick();