From 457db4f1488a4538930f2cfd3e0f3ac3899e9975 Mon Sep 17 00:00:00 2001 From: lavishaGit Date: Thu, 26 Sep 2024 09:22:47 -0700 Subject: [PATCH 1/4] wdio change in mobile cababilities --- .../config/wdio.config.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/browserstack_automation/config/wdio.config.js b/tests/browserstack_automation/config/wdio.config.js index 45e9efe0d..1396ee790 100644 --- a/tests/browserstack_automation/config/wdio.config.js +++ b/tests/browserstack_automation/config/wdio.config.js @@ -3,17 +3,17 @@ const { readFileSync } = require('fs'); const browserStackConfig = require('./browserstack.config'); const browserCapabilities = require('../capabilities/browser.json'); -let mobileCapabilities = []; +// let mobileCapabilities = []; -try { - const data = readFileSync('./tests/browserstack_automation/capabilities/mobile.json', { encoding: 'utf8' }); - mobileCapabilities = JSON.parse(data); -} catch (error) { - // Run `npm run wdio:setup` -} - -const capabilities = [...browserCapabilities, ...mobileCapabilities]; +// try { +// const data = readFileSync('./tests/browserstack_automation/capabilities/mobile.json', { encoding: 'utf8' }); +// mobileCapabilities = JSON.parse(data); +// } catch (error) { +// // Run `npm run wdio:setup` +// } +// const capabilities = [...browserCapabilities, ...mobileCapabilities]; +const capabilities = [...browserCapabilities]; const date = new Date(); const dateForDisplay = date.toDateString(); From 850147b5e08e99409dddc11cc0b34e385b273c73 Mon Sep 17 00:00:00 2001 From: lavishaGit Date: Thu, 3 Oct 2024 10:47:23 -0700 Subject: [PATCH 2/4] Signin page added --- .../page_objects/signin.page.js | 148 +++++ .../specs/SignInPage.js | 585 ++++++++++++++++++ 2 files changed, 733 insertions(+) create mode 100644 tests/browserstack_automation/page_objects/signin.page.js create mode 100644 tests/browserstack_automation/specs/SignInPage.js diff --git a/tests/browserstack_automation/page_objects/signin.page.js b/tests/browserstack_automation/page_objects/signin.page.js new file mode 100644 index 000000000..5f982276b --- /dev/null +++ b/tests/browserstack_automation/page_objects/signin.page.js @@ -0,0 +1,148 @@ +import { cardHeaderClasses } from '@mui/material'; +import {$,$$} from '@wdio/globals'; +import Page from './page'; + +class SignIn extends Page{ + /* constructor(){ + super().title= 'Ready to Vote? - WeVote'; + }*/ + + get signInLinkElement(){ + return $('.StyledButton-sc-1hu720d-1'); + } + get signInElement(){ + return $('.u-f3'); + } + + get signInWithTwitterTextElement(){ + return $('//span[text()="Sign in with Twitter"]'); + } + get signInWithAppleTextElement(){ + return $('//span[text()="Sign in with Apple"]'); // #appleSignInText + } + get twitterBttnElement(){ + return $('#twitterSignIn-splitIconButton'); + } + get appleBttnElement(){ + return $('.AppleSignInButton-sc-1tt5cpk-2'); + } + + + + get phoneNumberLabelElement(){ + return $('#enterVoterPhone-label'); + } + + get phoneNumberFieldElement(){ + return $('#enterVoterPhone'); + } + + get emailLabelElement(){ + return $('#enterVoterEmailAddress-label'); + } + + get emailFieldElement(){ + return $('#enterVoterEmailAddress'); + } +get iconElements(){ + return $$('#SignInOptionsMain-undefined svg'); + } + get cancelPhoneBttnElement(){ + return $('#cancelVoterPhoneSendSMS'); + } + get cancelEmailBttnElement(){ + return $('#cancelEmailButton'); + } + + get sendVerificationPhoneBttnElement(){ + return $('#voterPhoneSendSMS'); + } + get sendVerificationEmailBttnElement(){ + return $('#voterEmailAddressEntrySendCode'); + } + get closeBttnElement(){ + return $('#signInModalSimpleCloseIcon'); + } + get codeVerifyElement(){ + return $('.Title-sc-27qyt7-4'); + } + get backButtonElement(){ + return $('#emailVerificationBackButton'); +} +get sendVeificationAgainElement(){ + return $('//*[text()="Send verification again"]'); +} + async getIcons(){ + const iconList= await this.iconElements; + // for(const icon of iconList){ + // console.log('Icon: ${icon.toString()}'); // If toString() provides meaningful output + // } + const visibilityList = []; + + for(const icon of iconList){ + const isIconVisible =await icon.isDisplayed(); // call isDisplayed + visibilityList.push(isIconVisible); + } + return visibilityList; + } + + + async getText1(element) { + try { + const text = await element.getText(); + console.log(`Element extracted text is: ${text}`); + return text; + } catch (error) { + console.error('Error extracting text:', error); + return ''; + } + } + + randomString(length,withNum=false,withDecimal=false,withUnderscore=false,withDash=false){ + + let chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + let result=''; + let genresult='0123456789'; + if (withNum==true) { + chars = chars+'0123456789'; + } + +// if (withDecimal==true) { +// chars =chars+ '.'; +// } + +// if (withUnderscore==true) { +// chars = chars+'_'; +// } +// if(withDash==true){ +// chars=chars+'-' +// } + //console.log('Available characters:', chars); + for(let i=0;i '0123456789'.includes(char ))) { + // const randomIndex = Math.floor(Math.random() * chars.length); // Use parentheses for Math.random + // result = result + chars.charAt(randomIndex); + //for(let i=0;i<2;i++) + //{ + result=result+genresult.charAt(Math.floor(Math.random() * genresult.length)); + //} + }} + + return result; + + + + + } + + + +} +export default new SignIn(); diff --git a/tests/browserstack_automation/specs/SignInPage.js b/tests/browserstack_automation/specs/SignInPage.js new file mode 100644 index 000000000..1a027931c --- /dev/null +++ b/tests/browserstack_automation/specs/SignInPage.js @@ -0,0 +1,585 @@ +import { browser,driver, expect } from '@wdio/globals'; +import{describe, it } from 'mocha' +import { Key } from 'webdriverio'; +import { platform } from 'node:process'; +const os=require ('os'); +import ReadyPage from '../page_objects/ready.page'; +import SignIn from '../page_objects/signin.page'; +const { describe, it } = require('mocha'); + +const waitTime = 5000; + +beforeEach(async()=>{ + await ReadyPage.load(); ; + await driver.pause(waitTime); + await driver.maximizeWindow(); + await (await SignIn.signInLinkElement).click(); ///await driver.pause(waitTime); +}); + + +const testEmails = [ + //`${SignIn.randomString(1)}@w.us`, //cannot test with invalid 5 letters email because @w.us itself counted as 5 letters + `${SignIn.randomString(1)}@w.us`,//generates valid 6 letters email + `${SignIn.randomString(244)}@wevote.us`,//generates valid 254 letters email + `${SignIn.randomString(245)}@wevote.us` //generates invalid 255 letters email + ]; + + +describe('SignIn', () => { +// SignIn_001 + it('verifySignInPage', async () => { + + + await expect ( await SignIn.signInElement).toHaveText('Sign In or Join'); + }); + + // SignIn_002 and SignIn_007 and SignIn_008 + + + it('verifySpellingsOfAllElementsOnSignInPage', async () => { + const TwitterText="Sign in with Twitter"; + const AppleText="Sign in with Apple"; + //const phoneNumberLabelText = await SignIn.phoneNumberLabelElement; + //const elementText = await phoneNumberLabelText .getText(); +// Locate the input field + +// await ReadyPage.load(); +// await driver.pause(waitTime); +// await (await SignIn.signInLinkElement).click(); +// await driver.pause(waitTime); + + await expect(await SignIn.signInWithTwitterTextElement).toHaveText(TwitterText); +await expect(await SignIn.signInWithAppleTextElement).toHaveText(AppleText); +await expect(await SignIn.phoneNumberLabelElement).toHaveText("Mobile Phone Number"); +await expect(await SignIn.emailLabelElement).toHaveText("Email"); + + + /* const phoneNumberField = await SignIn.phoneNumberPlaceholderElement; + + // Get the placeholder attribute value + const phoneNumberplaceholderText = await phoneNumberField.getAttribute('placeholder'); + const emailField = await SignIn.emailPlaceholderElement; + await expect (phoneNumberplaceholderText ).toBe("Type phone number here...");*/ + await expect (await SignIn.phoneNumberFieldElement).toBeDisplayed(); + await expect (await SignIn.phoneNumberFieldElement.getAttribute('placeholder')).toBe("Type phone number here..."); + await expect (await SignIn.emailFieldElement).toBeDisplayed(); + await expect (await SignIn.emailFieldElement.getAttribute('placeholder')).toBe("Type email here..."); + + + }); + + // SignIn_003 + it('verifyAllIconsOnSignInPage', async () => { + + + // await ReadyPage.load(); + // await driver.pause(waitTime); + // await (await SignIn.signInLinkElement).click(); + // await driver.pause(waitTime); + + const iconsVisibility = await SignIn.getIcons(); + for(const iconVisible of iconsVisibility){ + await expect (iconVisible).toBe(true); + } + + + }); + +//SignIn_004 +it('verifyAllButtonsAndFieldsAlignedAndPresent', async () => { + + + // await ReadyPage.load(); + // await driver.pause(waitTime); + // await (await SignIn.signInLinkElement).click(); + // await driver.pause(waitTime); + + await expect (await SignIn.phoneNumberFieldElement).toBePresent(); + console.log("passed"); + await expect (await SignIn.emailFieldElement).toBePresent(); + console.log("passed"); + await expect (await SignIn.twitterBttnElement).toBePresent(); + console.log("passed"); + await expect (await SignIn.appleBttnElement).toBePresent(); + console.log("passed"); + + //const cssProperty = await SignIn.twitterElement.getCSSProperty('text-align'); + //await expect(cssProperty.value).toBe('center'); + await expect(await (await SignIn.twitterBttnElement.getCSSProperty('display')).value).toBe('inline-flex'); + console.log("twitter passed"); + // await expect(await(await SignIn.appleBttnElement.getCSSProperty('display')).value).toBe('inline-flex'); +// Error: expect(received).toBe(expected) // Object.is equality + +// Expected: "inline-flex" +// Received: "inline-block" + // console.log("apple passed"); + + await expect(await (await SignIn.phoneNumberFieldElement.getCSSProperty('display')).value).toBe('block'); + console.log("phoneNumber passed"); + + await expect(await (await SignIn.emailFieldElement.getCSSProperty('display')).value).toBe('block'); + console.log("emailField passed"); + + + + + await (await SignIn.phoneNumberFieldElement).click(); + //await (await SignIn.cancelPhoneBttnElement).waitForDisplayed(); + await expect(await (await SignIn.cancelPhoneBttnElement.getCSSProperty('display')).value).toBe('inline-flex'); + await expect (await SignIn.cancelPhoneBttnElement).toBePresent(); + console.log(" cancel passed"); + + await expect(await (await SignIn.sendVerificationPhoneBttnElement.getCSSProperty('display')).value).toBe('inline-flex'); +await expect(await SignIn.sendVerificationPhoneBttnElement).toBeDisabled();; +console.log("Its Disabled passed"); + + + }); +//SignIn_005 and SignIn_006 + +it('validateSendVerificationBttn',async() => { + // const randomNumber = Math.floor(40000000 + Math.random() * 9000000000); + const randomNumber = `4089${Math.floor(100000 + Math.random() * 900000)}`; + + const randomEmail = `user${Date.now()}@email.com`; +// await ReadyPage.load(); + +// await driver.pause(waitTime); +//await expect (await SignIn.signInLinkElement).toBeDisabled(); + +// await (await SignIn.signInLinkElement).click(); +await SignIn.phoneNumberFieldElement.click(); +console.log(randomNumber); +await SignIn.phoneNumberFieldElement.addValue(randomNumber); +await expect(await SignIn.sendVerificationPhoneBttnElement).toBeEnabled(); +console.log("phone verify passed"); +await SignIn.emailFieldElement.click(); +await SignIn.emailFieldElement.addValue(randomEmail); +await expect(await SignIn.sendVerificationEmailBttnElement).toBeEnabled(); +console.log(" email verify passed"); + +}); + +//SignIn_009 +it('verifyColorForContents', async()=>{ + +//console.log('Background color twitter :', await(await (await SignIn.twitterBttnElement).getCSSProperty('background-color')).value); +//console.log('Background color apple :', await(await (await SignIn.appleBttnElement).getCSSProperty('background-color')).value); + +const twitterbackgroundColor = await (await SignIn.twitterBttnElement).getCSSProperty('background-color'); +const applebackgroundColor= await (await SignIn.appleBttnElement).getCSSProperty('background-color'); +const twitterTextColor= await (await SignIn.signInWithTwitterTextElement).getCSSProperty('color'); +const appleTextColor= await (await SignIn.signInWithAppleTextElement).getCSSProperty('color'); +// Convert 'rgba' to 'rgb' by removing the alpha value if present +await expect(await twitterbackgroundColor.value.replace('rgba', 'rgb').replace(/,\s*1\)$/, ')')).toBe('rgb(85,172,238)'); + +await expect(await applebackgroundColor.value.replace('rgba', 'rgb').replace(/,\s*1\)$/, ')')).toBe('rgb(0,0,0)'); + +await expect(await twitterTextColor.value.replace('rgba', 'rgb').replace(/,\s*1\)$/, ')')).toBe('rgb(255,255,255)'); +await expect(await appleTextColor.value.replace('rgba', 'rgb').replace(/,\s*1\)$/, ')')).toBe('rgb(255,255,255)'); + +}); + + +//SignIn_010 and +it('verifyTwitterSignInLinkResponsiveness',async()=>{ + + +// await ReadyPage.load(); //await driver.pause(waitTime); + +// await (await SignIn.signInLinkElement).waitForClickable(); +// await (await SignIn.signInLinkElement).click(); + // await driver.pause(waitTime); + await (await SignIn.twitterBttnElement).waitForClickable(); + await SignIn.twitterBttnElement.click(); + await driver.waitUntil(async () => { + return await driver.getTitle()=== 'X / Authorize an application'}, { + timeout: 5000, + }); + + + // await expect (await driver.getTitle()).toBe('Twitter / Authorize an application'); + +}); +//SignIn_013 and SignIn_014 +it('verifyAppleSignInLinkResponsiveness',async()=>{ +await (await SignIn.appleBttnElement).waitForClickable(); + await SignIn.appleBttnElement.click(); + await driver.waitUntil(async () => {return await driver.getTitle()=== 'Sign in to Apple Account'}, { + timeout: 5000, + }); + await driver.back(); + +}); + + +//SignIn_15 and //SignIn_16 +it('verifyVisiblityOfPhoneAndEmailCancelAndSendBttn',async()=>{ + // let element = await SignIn.cancelPhoneBttnElement; + // console.log(element); + await SignIn.phoneNumberFieldElement.click(); + await expect(await SignIn.cancelPhoneBttnElement).toBeDisplayed(); + await expect(await SignIn.sendVerificationPhoneBttnElement).toBeDisplayed(); + await SignIn.emailFieldElement.click(); + await expect(await SignIn.cancelEmailBttnElement).toBeDisplayed(); + await expect(await SignIn.sendVerificationEmailBttnElement).toBeDisplayed(); + + +}); + + +//SignIn_017 and //SignIn_018 and //SignIn_019 and //SignIn_020 and //SignIn_021 and//SignIn_022 + +it('verifyTabKeyFunctionality',async()=>{ + await driver.keys('Tab'); + // await browser.keys('Tab');//first press tab +await expect(await SignIn.closeBttnElement).toBeFocused(); +await driver.keys('Tab','Tab'); +await expect(await SignIn.twitterBttnElement).toBeFocused(); +await driver.keys('Tab','Tab','Tab'); +await expect(await SignIn.appleBttnElement).toBeFocused(); +await driver.keys('Tab','Tab','Tab','Tab'); +await expect(await SignIn.phoneNumberFieldElement).toBeFocused(); +}); + + + +// //SignIn_026 +// it.only('verifyEmailFieldPasteFunctionalityUsingKeyboard',async()=>{ +// const testdata='wevote@wevote.us' +// //await SignIn.emailFieldElement.click(); + +// await SignIn.emailFieldElement.setValue(testdata); +// await driver.pause(5000); +// await driver.keys(['Command','a']) +// await driver.keys(['Command','c']); +// await driver.pause(5000); + +// // await driver.keys([Key.Command,'a']) +// // await driver.keys([Key.Command,'c']) +// await SignIn.emailFieldElement.setValue(''); + +// //await SignIn.emailFieldElement.clearValue(); +// await driver.pause(5000); +// await driver.keys(['Command','v']); +// await driver.pause(5000); +// const value = await SignIn.emailFieldElement.getValue(); +// await expect(value).toBe(testdata); + + + + + +// }); +//SignIn_026 +it('verifyEmailFieldPasteFunctionalityUsingKeyboard',async()=>{ + // console.log(`This platform is ${platform}`); + // console.log(process.env); + const testdata='wevote@wevote.us'; + const valueLength = testdata.length; + + const selector=await SignIn.emailFieldElement; + await (await SignIn.emailFieldElement).setValue(testdata); + await driver.pause(5000); +// if (process.platform === 'darwin') { +// console.log("running in macos");} +// else { +// console.log("running inother os"); +// } + //await SignIn.emailFieldElement.click(); +const platformName = browser.capabilities.platformName; // Gets the platform like 'Windows', 'macOS' +const browserName=browser.capabilities.browserName; +console.log(`Platform: ${platformName}`); +console.log(`Browser: ${browserName}`); +if(platformName==='Windows XP'&& browserName==='chrome'){ + +await browser.keys([Key.Control,'a']); +//await browser.keys('NULL'); // Releases the Ctrl key + +await browser.keys([Key.Control,'c']); +//await browser.keys('NULL'); +//for (let i = 0; i < valueLength; i++) { // Releases the Ctrl key + await browser.keys(Key.Backspace); + await SignIn.emailFieldElement.click(); + await browser.keys([Key.Control,'v']); +} + +if(platformName==='mac'&& browserName==='Safari') + { //For macOS, the correct value for process.platform is "darwin" +await browser.keys([Key.Command,'a']); + await browser.keys([Key.Command,'c']); + + await browser.keys(Key.Backspace); + await driver.keys([Key.Command,'v']); + + } + + const value = await SignIn.emailFieldElement.getValue(); + await expect(value).toBe(testdata); + + +}); +// //SignIn_028 +it('verifyEmailFieldWithValidAddress',async()=>{ + const testData='wevote@wevote.us'; + await SignIn.emailFieldElement.click(); + await (await SignIn.emailFieldElement).addValue(testData); + await (await SignIn.sendVerificationEmailBttnElement).click(); + const textData=await SignIn.codeVerifyElement.getText(); +await expect(textData).toBe('Code Verification'); + + +}); + +//SignIn_029 //SignIn_030 +it('verifyEmailFieldWithInvalidAddress',async()=>{ + const testDataNumber='11111'; + const testDataUrl= 'wevotewevote.us'; + await SignIn.emailFieldElement.click(); + await (await SignIn.emailFieldElement).addValue(testDataNumber); +const isClickableNumber=await(await SignIn.sendVerificationEmailBttnElement).isClickable(); + await expect(isClickableNumber).toBe(false); + await (await SignIn.emailFieldElement).setValue(testDataUrl); + const isClickableURL=await(await SignIn.sendVerificationEmailBttnElement).isClickable(); + await expect(isClickableURL).toBe(false); + + + }); + + + //SignIn_031 //SignIn_033 //SignIn_034 //SignIn_035 //SignIn_036 +it("verifyEmailFieldAcceptsOnlyLatinLetters",async()=>{ + +const withLatinLettersOnly=`${SignIn.randomString(6)}@wevote.us`; +//const lettersWithNumOnly=`${SignIn.randomString(6,true,false,false,false)}@wevote.us`; + //const lettersWithDecimalOnly=`${randomString(6,false,true)}@wevote.us`; + +// const lettersWithUnderscoreOnly=`${randomString(6,false,false,true)}@wevote.us`; +// + +// const lettersWithDashOnly=`${randomString(6,false,false,false,true)}@wevote.us`; + +await (await SignIn.emailFieldElement).setValue(withLatinLettersOnly); +const emailValue= await (await SignIn.emailFieldElement).getValue(); +console.log('email value ',emailValue); + +//await expect(emailValue).toBe(emailWithLatinLettersOnly); +await expect(emailValue).toMatch(/^[a-zA-Z]+@wevote\.us$/); +let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isClickable(); +await expect(isDisplayed).toBe(true); +//await (await SignIn.emailFieldElement).click(); // Focus on the field +// Use JavaScript to select all text in the input field + +//await (await SignIn.emailFieldElement).doubleClick(); // Focus on the field + await (await SignIn.emailFieldElement).setValue(''); // Clear using setValue + await driver.pause(waitTime); // Pause to ensure value is cleared + +// await (await SignIn.emailFieldElement).setValue(lettersWithNumOnly); +// const valueWithNum= await (await SignIn.emailFieldElement).getValue(); +// console.log('email value ',valueWithNum); +// await expect(valueWithNum).toMatch(/^[a-zA-Z0-9]+@wevote\.us$/); + +}); +//SignIn_033 + +it("verifyEmailFieldAcceptsLettersWithNum",async()=>{ +const lettersWithNumOnly=`${SignIn.randomString(6,true)}@wevote.us`;//const lettersWithNumOnly=`${SignIn.randomString(6,true,false,false,false)} +// or only need to use the parameters that are relevant for the string you want to generate. If you want a random string that includes numbers but excludes decimals, underscores, and dashes, you can simply call: const lettersWithNumOnly=`${SignIn.randomString(6,true)}`; + await (await SignIn.emailFieldElement).setValue(lettersWithNumOnly); + const valueWithNum= await (await SignIn.emailFieldElement).getValue(); + console.log('email value ',valueWithNum); + await expect(valueWithNum).toMatch(/^[a-zA-Z0-9]+@wevote\.us$/); + let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isClickable(); + await expect(isDisplayed).toBe(true); +//*************************setvalue/cleae value not working ********************/ + +// await (await SignIn.emailFieldElement).clearValue();; +// await driver.pause(10000); +// await (await SignIn.emailFieldElement).setValue(''); +// await driver.pause(10000); +//******************************************************************************** + +}); +//SignIn_034 +it("verifyEmailFieldAcceptsLettersWithDecimal",async()=>{ + const lettersWithDecimalOnly=`${SignIn.randomString(2)}.${SignIn.randomString(2)}@wevote.us`; +//const lettersWithNumOnly=`${SignIn.randomString(6,true,false,false,false)} + // or only need to use the parameters that are relevant for the string you want to generate. If you want a random string that includes numbers but excludes decimals, underscores, and dashes, you can simply call: const lettersWithNumOnly=`${SignIn.randomString(6,true)}`; + await (await SignIn.emailFieldElement).setValue(lettersWithDecimalOnly); + const valueWithDec= await (await SignIn.emailFieldElement).getValue(); + console.log('email value ',valueWithDec); + await expect(valueWithDec).toMatch(/^[a-zA-Z.]*\.[a-zA-Z.]*@wevote\.us$/); + let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isClickable(); + await expect(isDisplayed).toBe(true); + }); + //SignIn_035 +it("verifyEmailFieldAcceptsLettersWithUnderscore",async()=>{ + const lettersWithUnderscore=`${SignIn.randomString(2)}_${SignIn.randomString(2)}@wevote.us`; +//const lettersWithNumOnly=`${SignIn.randomString(6,true,false,false,false)} + // or only need to use the parameters that are relevant for the string you want to generate. If you want a random string that includes numbers but excludes decimals, underscores, and dashes, you can simply call: const lettersWithNumOnly=`${SignIn.randomString(6,true)}`; + await (await SignIn.emailFieldElement).setValue(lettersWithUnderscore); + const valueWithUnderscore= await (await SignIn.emailFieldElement).getValue(); + console.log('email value ',valueWithUnderscore); + await expect(valueWithUnderscore).toMatch(/^[a-zA-Z]*\_[a-zA-Z]*@wevote\.us$/); + let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isClickable(); + await expect(isDisplayed).toBe(true); +}); +// //SignIn_036 +it("verifyEmailFieldAcceptsLettersWithDash",async()=>{ + const lettersWithDash=`${SignIn.randomString(3)}-${SignIn.randomString(3)}@wevote.us`; +//const lettersWithNumOnly=`${SignIn.randomString(6,true,false,false,false)} + // or only need to use the parameters that are relevant for the string you want to generate. If you want a random string that includes numbers but excludes decimals, underscores, and dashes, you can simply call: const lettersWithNumOnly=`${SignIn.randomString(6,true)}`; + await (await SignIn.emailFieldElement).setValue(lettersWithDash); + const valueWithDash= await (await SignIn.emailFieldElement).getValue(); + console.log('email value ',valueWithDash); + await expect(valueWithDash).toMatch(/^[a-zA-Z]*\-[a-zA-Z]*@wevote\.us$/); + let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isClickable(); + await expect(isDisplayed).toBe(true); + }); + // //SignIn_037 +it("verifyEmailFieldDoesntAcceptStartWithDot",async()=>{ + const lettersStartWithDot=`.${SignIn.randomString(4)}@wevote.us`; + + await (await SignIn.emailFieldElement).setValue(lettersStartWithDot); + const valueStarWithDot= await (await SignIn.emailFieldElement).getValue(); + console.log('email value ',valueStarWithDot); + await expect(valueStarWithDot).toMatch(/^\.[a-zA-Z]*@wevote\.us$/); + let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isEnabled(); + await expect(isDisplayed).toBe(false); +}); +// //SignIn_040 +it("verifyEmailFieldDoesntAcceptStartWithDomain",async()=>{ + const lettersStartWithDomain=`@wevote.us`; + + await (await SignIn.emailFieldElement).setValue(lettersStartWithDomain); + const valueStarWithDomain= await (await SignIn.emailFieldElement).getValue(); + console.log('email value ',valueStarWithDomain); + await expect(valueStarWithDomain).toMatch(/^@wevote\.us$/); + let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isEnabled(); + await expect(isDisplayed).toBe(false); + +}); + + //SignIn_042 +it("verifyEmailFieldDoesntAcceptSpaces",async()=>{ + //*******************************Running in Safari only******************************************* */ + // const randomletters = `${SignIn.randomString(4)}`; + // const withSpace = ' '; + + // const randomletters1 = `${SignIn.randomString(2)}@wevote.us`; + // const lettersWithSpace = randomletters+withSpace+randomletters1 ; + // const lettersWithSpace=`${SignIn.randomString(2)} ${SignIn.randomString(1)}@wevote.us`; + if (os.platform() === 'win32') { + console.log('Running on Windows'); +} else if (os.platform() === 'darwin') { + console.log('Running on macOS'); +} else { + console.log(`Running on ${os.platform()}`); +} const platformName = browser.capabilities.platformName; // Gets the platform like 'Windows', 'macOS' + + const browserName = browser.capabilities.browserName; + console.log(`Platform: ${platformName}`); + console.log(`Browser: ${browserName}`); + + //space in chrome-windows not counted + // const lettersWithSpace=`${SignIn.randomString(2)} ${SignIn.randomString(2)}@wevote.us`; + + //const lettersWithSpace='We Vote@wevote.us'; + await (await SignIn.emailFieldElement).click(); + + + + + + await (await SignIn.emailFieldElement).addValue(`${SignIn.randomString(2)}`); + await (await SignIn.emailFieldElement).addValue(' '); + await (await SignIn.emailFieldElement).addValue(`${SignIn.randomString(2)}@wevote.us`); + const valueWithSpace= await (await SignIn.emailFieldElement).getValue(); + console.log('email value ',valueWithSpace); + await expect(valueWithSpace).toMatch(/^[a-zA-Z]* [a-zA-Z]*@wevote\.us$/); + let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isEnabled(); + await expect(isDisplayed).toBe(false); + +}); +//SignIn_045 +it("verifyEmailFieldWithBlank",async()=>{ + + await (await SignIn.emailFieldElement).setValue(' '); + const valueWithBlank= await (await SignIn.emailFieldElement).getValue(); + console.log('email value ',valueWithBlank); + await expect(valueWithBlank).toMatch(/^$/); // Validating that the value is empty + let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isEnabled(); + await expect(isDisplayed).toBe(false); + +}); + // //SignIn_046 +it("verifyEmailFieldAcceptsLettersWithTwoDots",async()=>{ + const lettersWithDoubleDots=`${SignIn.randomString(2)}.${SignIn.randomString(1)}.${SignIn.randomString(2)}@wevote.us`; + await (await SignIn.emailFieldElement).setValue(lettersWithDoubleDots); + const valueWithTwoDots= await (await SignIn.emailFieldElement).getValue(); + console.log('email value ',valueWithTwoDots); + await expect(valueWithTwoDots).toMatch(/^[a-zA-Z]*\.[a-zA-Z]*\.[a-zA-Z]*@wevote\.us$/); + let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isEnabled(); + await expect(isDisplayed).toBe(true); +}); + +//SignIn_047 +for(let email of testEmails){ +it('verifyEmailFieldAcceptsCharactersBetween6to254',async()=>{ + + + console.log(`Testing email: ${email}`); + console.log('email length:',email.length); + + await (await SignIn.emailFieldElement).setValue(email); + const emailValue= await (await SignIn.emailFieldElement).getValue(); +//console.log('email value ',emailValue); +const len=emailValue.length; +if(len>=6 && len<=254){ + await expect(await SignIn.cancelEmailBttnElement).toBeDisplayed(); + +await expect(await SignIn.sendVerificationEmailBttnElement).toBeEnabled(); +}else{ + + await expect(await SignIn.cancelEmailBttnElement).toBeDisplayed(); + +await expect(await SignIn.sendVerificationEmailBttnElement).not.toBeEnabled(); + + } + +}); +} + // //SignIn_052 + it('verifyBackButtonOnVerificationPage',async()=>{ + const lettersWithDoubleDots=`${SignIn.randomString(2)}.${SignIn.randomString(5)}@wevote.us`; + await (await SignIn.emailFieldElement).setValue(lettersWithDoubleDots); + + await (await SignIn.sendVerificationEmailBttnElement).click(); + await driver.waitUntil(async () => { + return await (await SignIn.codeVerifyElement).getText()=== 'Code Verification'}, { + timeout: 5000, + }); + await (await SignIn.backButtonElement).click(); + await expect (await SignIn.sendVeificationAgainElement).toBeDisplayed(); + +}); + +// //SignIn_054 +it('verifyCancelButtonClearEmailField',async()=>{ + const email=`${SignIn.randomString(5)}@wevote.us`; + await (await SignIn.emailFieldElement).setValue(email); + + await (await SignIn.cancelEmailBttnElement).click(); + const fieldvalue = await (await SignIn.emailFieldElement).getValue(); + await expect(fieldvalue).toBe(''); + await expect(await SignIn.cancelEmailBttnElement).not.toBeDisplayed(); + await expect(await SignIn.sendVerificationEmailBttnElement).not.toBeDisplayed(); + + //***********Both assertion works same way************************* + //await expect(fieldvalue).toHaveLength(0); + //await expect(fieldvalue).toEqual(''); +//*********************************************************** */ + + +}); +}); \ No newline at end of file From f9c23efe1fbb8f53683508d94c800b194245b748 Mon Sep 17 00:00:00 2001 From: lavishaGit <97263933+lavishaGit@users.noreply.github.com> Date: Thu, 3 Oct 2024 11:59:59 -0700 Subject: [PATCH 3/4] Update wdio.config.js --- .../config/wdio.config.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/browserstack_automation/config/wdio.config.js b/tests/browserstack_automation/config/wdio.config.js index 1396ee790..45e9efe0d 100644 --- a/tests/browserstack_automation/config/wdio.config.js +++ b/tests/browserstack_automation/config/wdio.config.js @@ -3,17 +3,17 @@ const { readFileSync } = require('fs'); const browserStackConfig = require('./browserstack.config'); const browserCapabilities = require('../capabilities/browser.json'); -// let mobileCapabilities = []; +let mobileCapabilities = []; -// try { -// const data = readFileSync('./tests/browserstack_automation/capabilities/mobile.json', { encoding: 'utf8' }); -// mobileCapabilities = JSON.parse(data); -// } catch (error) { -// // Run `npm run wdio:setup` -// } +try { + const data = readFileSync('./tests/browserstack_automation/capabilities/mobile.json', { encoding: 'utf8' }); + mobileCapabilities = JSON.parse(data); +} catch (error) { + // Run `npm run wdio:setup` +} + +const capabilities = [...browserCapabilities, ...mobileCapabilities]; -// const capabilities = [...browserCapabilities, ...mobileCapabilities]; -const capabilities = [...browserCapabilities]; const date = new Date(); const dateForDisplay = date.toDateString(); From 5fe1989c9db23ef6ea29402c262cf06459eb1acf Mon Sep 17 00:00:00 2001 From: lavishaGit Date: Tue, 8 Oct 2024 12:51:25 -0700 Subject: [PATCH 4/4] SignIn Page TestScripts --- .../page_objects/signin.page.js | 6 +- .../specs/SignInPage.js | 805 +++++++----------- 2 files changed, 328 insertions(+), 483 deletions(-) diff --git a/tests/browserstack_automation/page_objects/signin.page.js b/tests/browserstack_automation/page_objects/signin.page.js index 5f982276b..354374000 100644 --- a/tests/browserstack_automation/page_objects/signin.page.js +++ b/tests/browserstack_automation/page_objects/signin.page.js @@ -74,13 +74,9 @@ get sendVeificationAgainElement(){ } async getIcons(){ const iconList= await this.iconElements; - // for(const icon of iconList){ - // console.log('Icon: ${icon.toString()}'); // If toString() provides meaningful output - // } const visibilityList = []; - for(const icon of iconList){ - const isIconVisible =await icon.isDisplayed(); // call isDisplayed + const isIconVisible =await icon.isDisplayed()// call isDisplayed visibilityList.push(isIconVisible); } return visibilityList; diff --git a/tests/browserstack_automation/specs/SignInPage.js b/tests/browserstack_automation/specs/SignInPage.js index 1a027931c..fb8eed4a9 100644 --- a/tests/browserstack_automation/specs/SignInPage.js +++ b/tests/browserstack_automation/specs/SignInPage.js @@ -1,585 +1,434 @@ -import { browser,driver, expect } from '@wdio/globals'; -import{describe, it } from 'mocha' +import { browser, driver, expect } from '@wdio/globals'; import { Key } from 'webdriverio'; -import { platform } from 'node:process'; -const os=require ('os'); +import { isWebTarget } from 'webpack-dev-server'; +const os = require('os'); import ReadyPage from '../page_objects/ready.page'; import SignIn from '../page_objects/signin.page'; const { describe, it } = require('mocha'); const waitTime = 5000; -beforeEach(async()=>{ - await ReadyPage.load(); ; - await driver.pause(waitTime); +beforeEach(async () => { + await ReadyPage.load();; + //await driver.pause(waitTime); await driver.maximizeWindow(); - await (await SignIn.signInLinkElement).click(); ///await driver.pause(waitTime); + await (await SignIn.signInLinkElement).click(); }); const testEmails = [ //`${SignIn.randomString(1)}@w.us`, //cannot test with invalid 5 letters email because @w.us itself counted as 5 letters `${SignIn.randomString(1)}@w.us`,//generates valid 6 letters email - `${SignIn.randomString(244)}@wevote.us`,//generates valid 254 letters email - `${SignIn.randomString(245)}@wevote.us` //generates invalid 255 letters email - ]; + `${SignIn.randomString(244)}@wevote.us`,//generates valid 254 letters email + `${SignIn.randomString(245)}@wevote.us` //generates invalid 255 letters email +]; describe('SignIn', () => { -// SignIn_001 - it('verifySignInPage', async () => { - - await expect ( await SignIn.signInElement).toHaveText('Sign In or Join'); - }); - - // SignIn_002 and SignIn_007 and SignIn_008 - - - it('verifySpellingsOfAllElementsOnSignInPage', async () => { - const TwitterText="Sign in with Twitter"; - const AppleText="Sign in with Apple"; - //const phoneNumberLabelText = await SignIn.phoneNumberLabelElement; - //const elementText = await phoneNumberLabelText .getText(); -// Locate the input field - -// await ReadyPage.load(); -// await driver.pause(waitTime); -// await (await SignIn.signInLinkElement).click(); -// await driver.pause(waitTime); - - await expect(await SignIn.signInWithTwitterTextElement).toHaveText(TwitterText); -await expect(await SignIn.signInWithAppleTextElement).toHaveText(AppleText); -await expect(await SignIn.phoneNumberLabelElement).toHaveText("Mobile Phone Number"); -await expect(await SignIn.emailLabelElement).toHaveText("Email"); - - - /* const phoneNumberField = await SignIn.phoneNumberPlaceholderElement; - - // Get the placeholder attribute value - const phoneNumberplaceholderText = await phoneNumberField.getAttribute('placeholder'); - const emailField = await SignIn.emailPlaceholderElement; - await expect (phoneNumberplaceholderText ).toBe("Type phone number here...");*/ - await expect (await SignIn.phoneNumberFieldElement).toBeDisplayed(); - await expect (await SignIn.phoneNumberFieldElement.getAttribute('placeholder')).toBe("Type phone number here..."); - await expect (await SignIn.emailFieldElement).toBeDisplayed(); - await expect (await SignIn.emailFieldElement.getAttribute('placeholder')).toBe("Type email here..."); - - - }); - - // SignIn_003 - it('verifyAllIconsOnSignInPage', async () => { - - - // await ReadyPage.load(); - // await driver.pause(waitTime); - // await (await SignIn.signInLinkElement).click(); - // await driver.pause(waitTime); - - const iconsVisibility = await SignIn.getIcons(); - for(const iconVisible of iconsVisibility){ - await expect (iconVisible).toBe(true); - } - - - }); - -//SignIn_004 -it('verifyAllButtonsAndFieldsAlignedAndPresent', async () => { - - - // await ReadyPage.load(); - // await driver.pause(waitTime); - // await (await SignIn.signInLinkElement).click(); - // await driver.pause(waitTime); - - await expect (await SignIn.phoneNumberFieldElement).toBePresent(); - console.log("passed"); - await expect (await SignIn.emailFieldElement).toBePresent(); - console.log("passed"); - await expect (await SignIn.twitterBttnElement).toBePresent(); - console.log("passed"); - await expect (await SignIn.appleBttnElement).toBePresent(); - console.log("passed"); - - //const cssProperty = await SignIn.twitterElement.getCSSProperty('text-align'); - //await expect(cssProperty.value).toBe('center'); - await expect(await (await SignIn.twitterBttnElement.getCSSProperty('display')).value).toBe('inline-flex'); - console.log("twitter passed"); - // await expect(await(await SignIn.appleBttnElement.getCSSProperty('display')).value).toBe('inline-flex'); -// Error: expect(received).toBe(expected) // Object.is equality + // SignIn_001 + it('verifySignInPage', async () => { + await expect(await SignIn.signInElement).toHaveText('Sign In or Join'); + }); -// Expected: "inline-flex" -// Received: "inline-block" - // console.log("apple passed"); - await expect(await (await SignIn.phoneNumberFieldElement.getCSSProperty('display')).value).toBe('block'); - console.log("phoneNumber passed"); + // SignIn_002 and SignIn_007 and SignIn_008 + it('verifySpellingsOfAllElementsOnSignInPage', async () => { + const TwitterText = "Sign in with Twitter"; + const AppleText = "Sign in with Apple"; + await expect(SignIn.signInWithTwitterTextElement).toHaveText(TwitterText); + await expect(SignIn.signInWithAppleTextElement).toHaveText(AppleText); + await expect(SignIn.phoneNumberLabelElement).toHaveText("Mobile Phone Number"); + await expect(SignIn.emailLabelElement).toHaveText("Email"); + await expect(await SignIn.phoneNumberFieldElement).toBeDisplayed(); + await expect(await SignIn.phoneNumberFieldElement.getAttribute('placeholder')).toBe("Type phone number here..."); + await expect(await SignIn.emailFieldElement).toBeDisplayed(); + await expect(await SignIn.emailFieldElement.getAttribute('placeholder')).toBe("Type email here..."); - await expect(await (await SignIn.emailFieldElement.getCSSProperty('display')).value).toBe('block'); - console.log("emailField passed"); + }); - + // SignIn_003 + it('verifyAllIconsOnSignInPage', async () => { - await (await SignIn.phoneNumberFieldElement).click(); - //await (await SignIn.cancelPhoneBttnElement).waitForDisplayed(); - await expect(await (await SignIn.cancelPhoneBttnElement.getCSSProperty('display')).value).toBe('inline-flex'); - await expect (await SignIn.cancelPhoneBttnElement).toBePresent(); - console.log(" cancel passed"); + const iconsVisibility = await SignIn.getIcons(); + for (const iconVisible of iconsVisibility) { + await expect(iconVisible).toBe(true); + } - await expect(await (await SignIn.sendVerificationPhoneBttnElement.getCSSProperty('display')).value).toBe('inline-flex'); -await expect(await SignIn.sendVerificationPhoneBttnElement).toBeDisabled();; -console.log("Its Disabled passed"); + }); - }); -//SignIn_005 and SignIn_006 + //SignIn_004 + it('verifyAllButtonsAndFieldsAlignedAndPresent', async () => { -it('validateSendVerificationBttn',async() => { - // const randomNumber = Math.floor(40000000 + Math.random() * 9000000000); - const randomNumber = `4089${Math.floor(100000 + Math.random() * 900000)}`; + await expect(SignIn.phoneNumberFieldElement).toBePresent(); + await expect(SignIn.emailFieldElement).toBePresent(); - const randomEmail = `user${Date.now()}@email.com`; -// await ReadyPage.load(); + await expect(SignIn.twitterBttnElement).toBePresent(); -// await driver.pause(waitTime); -//await expect (await SignIn.signInLinkElement).toBeDisabled(); + await expect(SignIn.appleBttnElement).toBePresent(); -// await (await SignIn.signInLinkElement).click(); -await SignIn.phoneNumberFieldElement.click(); -console.log(randomNumber); -await SignIn.phoneNumberFieldElement.addValue(randomNumber); -await expect(await SignIn.sendVerificationPhoneBttnElement).toBeEnabled(); -console.log("phone verify passed"); -await SignIn.emailFieldElement.click(); -await SignIn.emailFieldElement.addValue(randomEmail); -await expect(await SignIn.sendVerificationEmailBttnElement).toBeEnabled(); -console.log(" email verify passed"); -}); + await expect(await (await SignIn.twitterBttnElement.getCSSProperty('display')).value).toBe('inline-flex'); -//SignIn_009 -it('verifyColorForContents', async()=>{ + await expect(await (await SignIn.phoneNumberFieldElement.getCSSProperty('display')).value).toBe('block'); -//console.log('Background color twitter :', await(await (await SignIn.twitterBttnElement).getCSSProperty('background-color')).value); -//console.log('Background color apple :', await(await (await SignIn.appleBttnElement).getCSSProperty('background-color')).value); + await expect(await (await SignIn.emailFieldElement.getCSSProperty('display')).value).toBe('block'); -const twitterbackgroundColor = await (await SignIn.twitterBttnElement).getCSSProperty('background-color'); -const applebackgroundColor= await (await SignIn.appleBttnElement).getCSSProperty('background-color'); -const twitterTextColor= await (await SignIn.signInWithTwitterTextElement).getCSSProperty('color'); -const appleTextColor= await (await SignIn.signInWithAppleTextElement).getCSSProperty('color'); -// Convert 'rgba' to 'rgb' by removing the alpha value if present -await expect(await twitterbackgroundColor.value.replace('rgba', 'rgb').replace(/,\s*1\)$/, ')')).toBe('rgb(85,172,238)'); + await (await SignIn.phoneNumberFieldElement).click(); + await expect(await (await SignIn.cancelPhoneBttnElement.getCSSProperty('display')).value).toBe('inline-flex'); + await expect(await SignIn.cancelPhoneBttnElement).toBePresent(); -await expect(await applebackgroundColor.value.replace('rgba', 'rgb').replace(/,\s*1\)$/, ')')).toBe('rgb(0,0,0)'); + await expect(await (await SignIn.sendVerificationPhoneBttnElement.getCSSProperty('display')).value).toBe('inline-flex'); + await expect(SignIn.sendVerificationPhoneBttnElement).toBeDisabled();; -await expect(await twitterTextColor.value.replace('rgba', 'rgb').replace(/,\s*1\)$/, ')')).toBe('rgb(255,255,255)'); -await expect(await appleTextColor.value.replace('rgba', 'rgb').replace(/,\s*1\)$/, ')')).toBe('rgb(255,255,255)'); - -}); + }); + //SignIn_005 and SignIn_006 -//SignIn_010 and -it('verifyTwitterSignInLinkResponsiveness',async()=>{ + it('validateSendVerificationBttn', async () => { + const randomNumber = `4089${Math.floor(100000 + Math.random() * 900000)}`; + const randomEmail = `user${Date.now()}@email.com`; + + await SignIn.phoneNumberFieldElement.click(); + await expect(SignIn.sendVerificationPhoneBttnElement).not.toBeEnabled(); -// await ReadyPage.load(); //await driver.pause(waitTime); + await SignIn.phoneNumberFieldElement.addValue(randomNumber); + await expect(SignIn.sendVerificationPhoneBttnElement).toBeEnabled(); + await SignIn.emailFieldElement.click(); + await expect (SignIn.sendVerificationEmailBttnElement).not.toBeEnabled(); -// await (await SignIn.signInLinkElement).waitForClickable(); -// await (await SignIn.signInLinkElement).click(); - // await driver.pause(waitTime); - await (await SignIn.twitterBttnElement).waitForClickable(); - await SignIn.twitterBttnElement.click(); - await driver.waitUntil(async () => { - return await driver.getTitle()=== 'X / Authorize an application'}, { - timeout: 5000, - }); - + await SignIn.emailFieldElement.addValue(randomEmail); + await expect(SignIn.sendVerificationEmailBttnElement).toBeEnabled(); - // await expect (await driver.getTitle()).toBe('Twitter / Authorize an application'); - -}); -//SignIn_013 and SignIn_014 -it('verifyAppleSignInLinkResponsiveness',async()=>{ -await (await SignIn.appleBttnElement).waitForClickable(); - await SignIn.appleBttnElement.click(); - await driver.waitUntil(async () => {return await driver.getTitle()=== 'Sign in to Apple Account'}, { - timeout: 5000, }); - await driver.back(); -}); + //SignIn_009 + it('verifyColorForContents', async () => { + const twitterbackgroundColor = await (SignIn.twitterBttnElement).getCSSProperty('background-color'); + const applebackgroundColor = await (SignIn.appleBttnElement).getCSSProperty('background-color'); + const twitterTextColor = await (SignIn.signInWithTwitterTextElement).getCSSProperty('color'); + const appleTextColor = await (SignIn.signInWithAppleTextElement).getCSSProperty('color'); + // Convert 'rgba' to 'rgb' by removing the alpha value if present + await expect(await twitterbackgroundColor.value.replace('rgba', 'rgb').replace(/,\s*1\)$/, ')')).toBe('rgb(85,172,238)'); -//SignIn_15 and //SignIn_16 -it('verifyVisiblityOfPhoneAndEmailCancelAndSendBttn',async()=>{ - // let element = await SignIn.cancelPhoneBttnElement; - // console.log(element); - await SignIn.phoneNumberFieldElement.click(); - await expect(await SignIn.cancelPhoneBttnElement).toBeDisplayed(); - await expect(await SignIn.sendVerificationPhoneBttnElement).toBeDisplayed(); - await SignIn.emailFieldElement.click(); - await expect(await SignIn.cancelEmailBttnElement).toBeDisplayed(); - await expect(await SignIn.sendVerificationEmailBttnElement).toBeDisplayed(); + await expect(await applebackgroundColor.value.replace('rgba', 'rgb').replace(/,\s*1\)$/, ')')).toBe('rgb(0,0,0)'); + await expect(await twitterTextColor.value.replace('rgba', 'rgb').replace(/,\s*1\)$/, ')')).toBe('rgb(255,255,255)'); + await expect(await appleTextColor.value.replace('rgba', 'rgb').replace(/,\s*1\)$/, ')')).toBe('rgb(255,255,255)'); -}); + }); -//SignIn_017 and //SignIn_018 and //SignIn_019 and //SignIn_020 and //SignIn_021 and//SignIn_022 + //SignIn_010 + it('verifyTwitterSignInLinkResponsiveness', async () => { -it('verifyTabKeyFunctionality',async()=>{ - await driver.keys('Tab'); - // await browser.keys('Tab');//first press tab -await expect(await SignIn.closeBttnElement).toBeFocused(); -await driver.keys('Tab','Tab'); -await expect(await SignIn.twitterBttnElement).toBeFocused(); -await driver.keys('Tab','Tab','Tab'); -await expect(await SignIn.appleBttnElement).toBeFocused(); -await driver.keys('Tab','Tab','Tab','Tab'); -await expect(await SignIn.phoneNumberFieldElement).toBeFocused(); -}); + await SignIn.twitterBttnElement.waitForClickable(); + await SignIn.twitterBttnElement.click(); + await driver.waitUntil(async () => { + return await driver.getTitle() === 'X / Authorize an application' + }, { + timeout: 5000, + }); -// //SignIn_026 -// it.only('verifyEmailFieldPasteFunctionalityUsingKeyboard',async()=>{ -// const testdata='wevote@wevote.us' -// //await SignIn.emailFieldElement.click(); -// await SignIn.emailFieldElement.setValue(testdata); -// await driver.pause(5000); -// await driver.keys(['Command','a']) -// await driver.keys(['Command','c']); -// await driver.pause(5000); + }); + //SignIn_013 and SignIn_014 + it('verifyAppleSignInLinkResponsiveness', async () => { + await SignIn.appleBttnElement.waitForClickable(); + await SignIn.appleBttnElement.click(); + await driver.waitUntil(async () => { return await driver.getTitle() === 'Sign in to Apple Account' }, { + timeout: 5000, + }); + await driver.back(); + await expect(await SignIn.signInElement).toHaveText('Sign In or Join'); -// // await driver.keys([Key.Command,'a']) -// // await driver.keys([Key.Command,'c']) -// await SignIn.emailFieldElement.setValue(''); + }); -// //await SignIn.emailFieldElement.clearValue(); -// await driver.pause(5000); -// await driver.keys(['Command','v']); -// await driver.pause(5000); -// const value = await SignIn.emailFieldElement.getValue(); -// await expect(value).toBe(testdata); + //SignIn_15 and //SignIn_16 + it('verifyVisiblityOfPhoneAndEmailCancelAndSendBttn', async () => { + + await SignIn.phoneNumberFieldElement.click(); + await expect(SignIn.cancelPhoneBttnElement).toBeDisplayed(); + await expect(SignIn.sendVerificationPhoneBttnElement).toBeDisplayed(); + await SignIn.emailFieldElement.click(); + await expect(SignIn.cancelEmailBttnElement).toBeDisplayed(); + await expect(SignIn.sendVerificationEmailBttnElement).toBeDisplayed(); + }); -// }); -//SignIn_026 -it('verifyEmailFieldPasteFunctionalityUsingKeyboard',async()=>{ - // console.log(`This platform is ${platform}`); - // console.log(process.env); - const testdata='wevote@wevote.us'; - const valueLength = testdata.length; + //SignIn_017 and //SignIn_018 and //SignIn_019 and //SignIn_020 and //SignIn_021 and//SignIn_022 - const selector=await SignIn.emailFieldElement; - await (await SignIn.emailFieldElement).setValue(testdata); - await driver.pause(5000); -// if (process.platform === 'darwin') { -// console.log("running in macos");} -// else { -// console.log("running inother os"); -// } - //await SignIn.emailFieldElement.click(); -const platformName = browser.capabilities.platformName; // Gets the platform like 'Windows', 'macOS' -const browserName=browser.capabilities.browserName; -console.log(`Platform: ${platformName}`); -console.log(`Browser: ${browserName}`); -if(platformName==='Windows XP'&& browserName==='chrome'){ + it('verifyTabKeyFunctionality', async () => { + await driver.keys('Tab'); + // await browser.keys('Tab');//first press tab + await expect(await SignIn.closeBttnElement).toBeFocused(); + await driver.keys('Tab', 'Tab'); + await expect(await SignIn.twitterBttnElement).toBeFocused(); + await driver.keys('Tab', 'Tab', 'Tab'); + await expect(await SignIn.appleBttnElement).toBeFocused(); + await driver.keys('Tab', 'Tab', 'Tab', 'Tab'); + await expect(await SignIn.phoneNumberFieldElement).toBeFocused(); + }); -await browser.keys([Key.Control,'a']); -//await browser.keys('NULL'); // Releases the Ctrl key -await browser.keys([Key.Control,'c']); -//await browser.keys('NULL'); -//for (let i = 0; i < valueLength; i++) { // Releases the Ctrl key - await browser.keys(Key.Backspace); - await SignIn.emailFieldElement.click(); - await browser.keys([Key.Control,'v']); -} + //SignIn_026 + it('verifyEmailFieldPasteFunctionalityUsingKeyboard', async () => { + + const testdata = 'wevote@wevote.us'; + const valueLength = testdata.length; -if(platformName==='mac'&& browserName==='Safari') - { //For macOS, the correct value for process.platform is "darwin" -await browser.keys([Key.Command,'a']); - await browser.keys([Key.Command,'c']); + const selector = await SignIn.emailFieldElement; + await SignIn.emailFieldElement.setValue(testdata); + await driver.pause(5000); + + const platformName = browser.capabilities.platformName; // Gets the platform like 'Windows', 'macOS' + const browserName = browser.capabilities.browserName; + console.log(`Platform: ${platformName}`); + console.log(`Browser: ${browserName}`); + if (platformName === 'Windows XP' && browserName === 'chrome') { - await browser.keys(Key.Backspace); - await driver.keys([Key.Command,'v']); + await browser.keys([Key.Control, 'a']); + //await browser.keys('NULL'); // Releases the Ctrl key + await browser.keys([Key.Control, 'c']); + //await browser.keys('NULL'); + //for (let i = 0; i < valueLength; i++) { // Releases the Ctrl key + await browser.keys(Key.Backspace); + await SignIn.emailFieldElement.click(); + await browser.keys([Key.Control, 'v']); + } - } + if (platformName === 'mac' && browserName === 'Safari') { //For macOS, the correct value for process.platform is "darwin" + await browser.keys([Key.Command, 'a']); + await browser.keys([Key.Command, 'c']); - const value = await SignIn.emailFieldElement.getValue(); - await expect(value).toBe(testdata); - + await browser.keys(Key.Backspace); + await driver.keys([Key.Command, 'v']); -}); -// //SignIn_028 -it('verifyEmailFieldWithValidAddress',async()=>{ - const testData='wevote@wevote.us'; - await SignIn.emailFieldElement.click(); - await (await SignIn.emailFieldElement).addValue(testData); - await (await SignIn.sendVerificationEmailBttnElement).click(); - const textData=await SignIn.codeVerifyElement.getText(); -await expect(textData).toBe('Code Verification'); + } + const value = await SignIn.emailFieldElement.getValue(); + await expect(value).toBe(testdata); -}); -//SignIn_029 //SignIn_030 -it('verifyEmailFieldWithInvalidAddress',async()=>{ - const testDataNumber='11111'; - const testDataUrl= 'wevotewevote.us'; - await SignIn.emailFieldElement.click(); - await (await SignIn.emailFieldElement).addValue(testDataNumber); -const isClickableNumber=await(await SignIn.sendVerificationEmailBttnElement).isClickable(); - await expect(isClickableNumber).toBe(false); - await (await SignIn.emailFieldElement).setValue(testDataUrl); - const isClickableURL=await(await SignIn.sendVerificationEmailBttnElement).isClickable(); - await expect(isClickableURL).toBe(false); + }); + // //SignIn_028 + it('verifyEmailFieldWithValidAddress', async () => { + const testData = 'wevote@wevote.us'; + await SignIn.emailFieldElement.click(); + await SignIn.emailFieldElement.addValue(testData); + await SignIn.sendVerificationEmailBttnElement.click(); + const textData = await SignIn.codeVerifyElement.getText(); + await expect(textData).toBe('Code Verification'); }); + //SignIn_029 //SignIn_030 + it('verifyEmailFieldWithInvalidAddress', async () => { + const testDataNumber = '11111'; + const testDataUrl = 'wevotewevote.us'; + await SignIn.emailFieldElement.click(); + await SignIn.emailFieldElement.addValue(testDataNumber); + const isClickableNumber = await (await SignIn.sendVerificationEmailBttnElement).isClickable(); + await expect(isClickableNumber).toBe(false); + await SignIn.emailFieldElement.setValue(testDataUrl); + const isClickableURL = await (await SignIn.sendVerificationEmailBttnElement).isClickable(); + await expect(isClickableURL).toBe(false); - //SignIn_031 //SignIn_033 //SignIn_034 //SignIn_035 //SignIn_036 -it("verifyEmailFieldAcceptsOnlyLatinLetters",async()=>{ - -const withLatinLettersOnly=`${SignIn.randomString(6)}@wevote.us`; -//const lettersWithNumOnly=`${SignIn.randomString(6,true,false,false,false)}@wevote.us`; - //const lettersWithDecimalOnly=`${randomString(6,false,true)}@wevote.us`; -// const lettersWithUnderscoreOnly=`${randomString(6,false,false,true)}@wevote.us`; -// + }); -// const lettersWithDashOnly=`${randomString(6,false,false,false,true)}@wevote.us`; -await (await SignIn.emailFieldElement).setValue(withLatinLettersOnly); -const emailValue= await (await SignIn.emailFieldElement).getValue(); -console.log('email value ',emailValue); + //SignIn_031 + it("verifyEmailFieldAcceptsOnlyLatinLetters", async () => { -//await expect(emailValue).toBe(emailWithLatinLettersOnly); -await expect(emailValue).toMatch(/^[a-zA-Z]+@wevote\.us$/); -let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isClickable(); -await expect(isDisplayed).toBe(true); -//await (await SignIn.emailFieldElement).click(); // Focus on the field -// Use JavaScript to select all text in the input field + const withLatinLettersOnly = `${SignIn.randomString(6)}@wevote.us`; + await SignIn.emailFieldElement.setValue(withLatinLettersOnly); + const emailValue = await SignIn.emailFieldElement.getValue(); + console.log('email value ', emailValue); + await expect(emailValue).toMatch(/^[a-zA-Z]+@wevote\.us$/); + let isDisplayed = await SignIn.sendVerificationEmailBttnElement.isClickable(); + await expect(isDisplayed).toBe(true); -//await (await SignIn.emailFieldElement).doubleClick(); // Focus on the field - await (await SignIn.emailFieldElement).setValue(''); // Clear using setValue - await driver.pause(waitTime); // Pause to ensure value is cleared + //await SignIn.emailFieldElement.setValue(''); // Clear using setValue + // await driver.pause(waitTime); // Pause to ensure value is cleared -// await (await SignIn.emailFieldElement).setValue(lettersWithNumOnly); -// const valueWithNum= await (await SignIn.emailFieldElement).getValue(); -// console.log('email value ',valueWithNum); -// await expect(valueWithNum).toMatch(/^[a-zA-Z0-9]+@wevote\.us$/); -}); -//SignIn_033 - -it("verifyEmailFieldAcceptsLettersWithNum",async()=>{ -const lettersWithNumOnly=`${SignIn.randomString(6,true)}@wevote.us`;//const lettersWithNumOnly=`${SignIn.randomString(6,true,false,false,false)} -// or only need to use the parameters that are relevant for the string you want to generate. If you want a random string that includes numbers but excludes decimals, underscores, and dashes, you can simply call: const lettersWithNumOnly=`${SignIn.randomString(6,true)}`; - await (await SignIn.emailFieldElement).setValue(lettersWithNumOnly); - const valueWithNum= await (await SignIn.emailFieldElement).getValue(); - console.log('email value ',valueWithNum); - await expect(valueWithNum).toMatch(/^[a-zA-Z0-9]+@wevote\.us$/); - let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isClickable(); - await expect(isDisplayed).toBe(true); -//*************************setvalue/cleae value not working ********************/ - -// await (await SignIn.emailFieldElement).clearValue();; -// await driver.pause(10000); -// await (await SignIn.emailFieldElement).setValue(''); -// await driver.pause(10000); -//******************************************************************************** + }); + //SignIn_033 + + it("verifyEmailFieldAcceptsLettersWithNum", async () => { + const lettersWithNumOnly = `${SignIn.randomString(6, true)}@wevote.us`;//const lettersWithNumOnly=`${SignIn.randomString(6,true,false,false,false)} + // or only need to use the parameters that are relevant for the string you want to generate. If you want a random string that includes numbers but excludes decimals, underscores, and dashes, you can simply call: const lettersWithNumOnly=`${SignIn.randomString(6,true)}`; + await (await SignIn.emailFieldElement).setValue(lettersWithNumOnly); + const valueWithNum = await (await SignIn.emailFieldElement).getValue(); + console.log('email value ', valueWithNum); + await expect(valueWithNum).toMatch(/^[a-zA-Z0-9]+@wevote\.us$/); + let isDisplayed = await (await SignIn.sendVerificationEmailBttnElement).isClickable(); + await expect(isDisplayed).toBe(true); + + }); + //SignIn_034 + it("verifyEmailFieldAcceptsLettersWithDecimal", async () => { + const lettersWithDecimalOnly = `${SignIn.randomString(2)}.${SignIn.randomString(2)}@wevote.us`; + await (await SignIn.emailFieldElement).setValue(lettersWithDecimalOnly); + const valueWithDec = await (await SignIn.emailFieldElement).getValue(); + console.log('email value ', valueWithDec); + await expect(valueWithDec).toMatch(/^[a-zA-Z.]*\.[a-zA-Z.]*@wevote\.us$/); + let isDisplayed = await (await SignIn.sendVerificationEmailBttnElement).isClickable(); + + await expect(isDisplayed).toBe(true); + }); + //SignIn_035 + it("verifyEmailFieldAcceptsLettersWithUnderscore", async () => { + const lettersWithUnderscore = `${SignIn.randomString(2)}_${SignIn.randomString(2)}@wevote.us`; + await (await SignIn.emailFieldElement).setValue(lettersWithUnderscore); + const valueWithUnderscore = await (await SignIn.emailFieldElement).getValue(); + console.log('email value ', valueWithUnderscore); + await expect(valueWithUnderscore).toMatch(/^[a-zA-Z]*\_[a-zA-Z]*@wevote\.us$/); + let isDisplayed = await (await SignIn.sendVerificationEmailBttnElement).isClickable(); + await expect(isDisplayed).toBe(true); + }); + // //SignIn_036 + it("verifyEmailFieldAcceptsLettersWithDash", async () => { + const lettersWithDash = `${SignIn.randomString(3)}-${SignIn.randomString(3)}@wevote.us`; + await (await SignIn.emailFieldElement).setValue(lettersWithDash); + const valueWithDash = await (await SignIn.emailFieldElement).getValue(); + console.log('email value ', valueWithDash); + await expect(valueWithDash).toMatch(/^[a-zA-Z]*\-[a-zA-Z]*@wevote\.us$/); + let isDisplayed = await (await SignIn.sendVerificationEmailBttnElement).isClickable(); + await expect(isDisplayed).toBe(true); + }); + // //SignIn_037 + it("verifyEmailFieldDoesntAcceptStartWithDot", async () => { + const lettersStartWithDot = `.${SignIn.randomString(4)}@wevote.us`; + await (await SignIn.emailFieldElement).setValue(lettersStartWithDot); + const valueStarWithDot = await (await SignIn.emailFieldElement).getValue(); + console.log('email value ', valueStarWithDot); + await expect(valueStarWithDot).toMatch(/^\.[a-zA-Z]*@wevote\.us$/); + let isDisplayed = await (await SignIn.sendVerificationEmailBttnElement).isEnabled(); + await expect(isDisplayed).toBe(false); + }); + // //SignIn_040 + it("verifyEmailFieldDoesntAcceptStartWithDomain", async () => { + const lettersStartWithDomain = `@wevote.us`; + await (await SignIn.emailFieldElement).setValue(lettersStartWithDomain); + const valueStarWithDomain = await (await SignIn.emailFieldElement).getValue(); + console.log('email value ', valueStarWithDomain); + await expect(valueStarWithDomain).toMatch(/^@wevote\.us$/); + let isDisplayed = await (await SignIn.sendVerificationEmailBttnElement).isEnabled(); + await expect(isDisplayed).toBe(false); -}); -//SignIn_034 -it("verifyEmailFieldAcceptsLettersWithDecimal",async()=>{ - const lettersWithDecimalOnly=`${SignIn.randomString(2)}.${SignIn.randomString(2)}@wevote.us`; -//const lettersWithNumOnly=`${SignIn.randomString(6,true,false,false,false)} - // or only need to use the parameters that are relevant for the string you want to generate. If you want a random string that includes numbers but excludes decimals, underscores, and dashes, you can simply call: const lettersWithNumOnly=`${SignIn.randomString(6,true)}`; - await (await SignIn.emailFieldElement).setValue(lettersWithDecimalOnly); - const valueWithDec= await (await SignIn.emailFieldElement).getValue(); - console.log('email value ',valueWithDec); - await expect(valueWithDec).toMatch(/^[a-zA-Z.]*\.[a-zA-Z.]*@wevote\.us$/); - let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isClickable(); - await expect(isDisplayed).toBe(true); }); - //SignIn_035 -it("verifyEmailFieldAcceptsLettersWithUnderscore",async()=>{ - const lettersWithUnderscore=`${SignIn.randomString(2)}_${SignIn.randomString(2)}@wevote.us`; -//const lettersWithNumOnly=`${SignIn.randomString(6,true,false,false,false)} - // or only need to use the parameters that are relevant for the string you want to generate. If you want a random string that includes numbers but excludes decimals, underscores, and dashes, you can simply call: const lettersWithNumOnly=`${SignIn.randomString(6,true)}`; - await (await SignIn.emailFieldElement).setValue(lettersWithUnderscore); - const valueWithUnderscore= await (await SignIn.emailFieldElement).getValue(); - console.log('email value ',valueWithUnderscore); - await expect(valueWithUnderscore).toMatch(/^[a-zA-Z]*\_[a-zA-Z]*@wevote\.us$/); - let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isClickable(); - await expect(isDisplayed).toBe(true); -}); -// //SignIn_036 -it("verifyEmailFieldAcceptsLettersWithDash",async()=>{ - const lettersWithDash=`${SignIn.randomString(3)}-${SignIn.randomString(3)}@wevote.us`; -//const lettersWithNumOnly=`${SignIn.randomString(6,true,false,false,false)} - // or only need to use the parameters that are relevant for the string you want to generate. If you want a random string that includes numbers but excludes decimals, underscores, and dashes, you can simply call: const lettersWithNumOnly=`${SignIn.randomString(6,true)}`; - await (await SignIn.emailFieldElement).setValue(lettersWithDash); - const valueWithDash= await (await SignIn.emailFieldElement).getValue(); - console.log('email value ',valueWithDash); - await expect(valueWithDash).toMatch(/^[a-zA-Z]*\-[a-zA-Z]*@wevote\.us$/); - let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isClickable(); - await expect(isDisplayed).toBe(true); - }); - // //SignIn_037 -it("verifyEmailFieldDoesntAcceptStartWithDot",async()=>{ - const lettersStartWithDot=`.${SignIn.randomString(4)}@wevote.us`; - - await (await SignIn.emailFieldElement).setValue(lettersStartWithDot); - const valueStarWithDot= await (await SignIn.emailFieldElement).getValue(); - console.log('email value ',valueStarWithDot); - await expect(valueStarWithDot).toMatch(/^\.[a-zA-Z]*@wevote\.us$/); - let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isEnabled(); - await expect(isDisplayed).toBe(false); -}); -// //SignIn_040 -it("verifyEmailFieldDoesntAcceptStartWithDomain",async()=>{ - const lettersStartWithDomain=`@wevote.us`; - await (await SignIn.emailFieldElement).setValue(lettersStartWithDomain); - const valueStarWithDomain= await (await SignIn.emailFieldElement).getValue(); - console.log('email value ',valueStarWithDomain); - await expect(valueStarWithDomain).toMatch(/^@wevote\.us$/); - let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isEnabled(); - await expect(isDisplayed).toBe(false); + //SignIn_042 //This code works only in Running in Safari only so commented out + // it("verifyEmailFieldDoesntAcceptSpaces", async () => { + + + // const browserName = browser.capabilities.browserName; + // console.log(`Platform: ${platformName}`); + // console.log(`Browser: ${browserName}`); + + // await (await SignIn.emailFieldElement).click(); + // await (await SignIn.emailFieldElement).addValue(`${SignIn.randomString(2)}`); + // await (await SignIn.emailFieldElement).addValue(' '); + // await (await SignIn.emailFieldElement).addValue(`${SignIn.randomString(2)}@wevote.us`); + // const valueWithSpace = await (await SignIn.emailFieldElement).getValue(); + // console.log('email value ', valueWithSpace); + // await expect(valueWithSpace).toMatch(/^[a-zA-Z]* [a-zA-Z]*@wevote\.us$/); + // let isDisplayed = await (await SignIn.sendVerificationEmailBttnElement).isEnabled(); + // await expect(isDisplayed).toBe(false); + + // }); + //SignIn_045 + it("verifyEmailFieldWithBlank", async () => { + + await (await SignIn.emailFieldElement).setValue(' '); + const valueWithBlank = await (await SignIn.emailFieldElement).getValue(); + console.log('email value ', valueWithBlank); + await expect(valueWithBlank).toMatch(/^$/); // Validating that the value is empty + let isDisplayed = await (await SignIn.sendVerificationEmailBttnElement).isEnabled(); + await expect(isDisplayed).toBe(false); -}); - - //SignIn_042 -it("verifyEmailFieldDoesntAcceptSpaces",async()=>{ - //*******************************Running in Safari only******************************************* */ - // const randomletters = `${SignIn.randomString(4)}`; - // const withSpace = ' '; - - // const randomletters1 = `${SignIn.randomString(2)}@wevote.us`; - // const lettersWithSpace = randomletters+withSpace+randomletters1 ; - // const lettersWithSpace=`${SignIn.randomString(2)} ${SignIn.randomString(1)}@wevote.us`; - if (os.platform() === 'win32') { - console.log('Running on Windows'); -} else if (os.platform() === 'darwin') { - console.log('Running on macOS'); -} else { - console.log(`Running on ${os.platform()}`); -} const platformName = browser.capabilities.platformName; // Gets the platform like 'Windows', 'macOS' - - const browserName = browser.capabilities.browserName; - console.log(`Platform: ${platformName}`); - console.log(`Browser: ${browserName}`); - - //space in chrome-windows not counted - // const lettersWithSpace=`${SignIn.randomString(2)} ${SignIn.randomString(2)}@wevote.us`; - - //const lettersWithSpace='We Vote@wevote.us'; - await (await SignIn.emailFieldElement).click(); - - - - - - await (await SignIn.emailFieldElement).addValue(`${SignIn.randomString(2)}`); - await (await SignIn.emailFieldElement).addValue(' '); - await (await SignIn.emailFieldElement).addValue(`${SignIn.randomString(2)}@wevote.us`); - const valueWithSpace= await (await SignIn.emailFieldElement).getValue(); - console.log('email value ',valueWithSpace); - await expect(valueWithSpace).toMatch(/^[a-zA-Z]* [a-zA-Z]*@wevote\.us$/); - let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isEnabled(); - await expect(isDisplayed).toBe(false); + }); + // //SignIn_046 + it("verifyEmailFieldAcceptsLettersWithTwoDots", async () => { + const lettersWithDoubleDots = `${SignIn.randomString(2)}.${SignIn.randomString(1)}.${SignIn.randomString(2)}@wevote.us`; + await (await SignIn.emailFieldElement).setValue(lettersWithDoubleDots); + const valueWithTwoDots = await (await SignIn.emailFieldElement).getValue(); + console.log('email value ', valueWithTwoDots); + await expect(valueWithTwoDots).toMatch(/^[a-zA-Z]*\.[a-zA-Z]*\.[a-zA-Z]*@wevote\.us$/); + let isDisplayed = await (await SignIn.sendVerificationEmailBttnElement).isEnabled(); + await expect(isDisplayed).toBe(true); + }); -}); -//SignIn_045 -it("verifyEmailFieldWithBlank",async()=>{ + //SignIn_047 + for (let email of testEmails) { + it('verifyEmailFieldAcceptsCharactersBetween6to254', async () => { - await (await SignIn.emailFieldElement).setValue(' '); - const valueWithBlank= await (await SignIn.emailFieldElement).getValue(); - console.log('email value ',valueWithBlank); - await expect(valueWithBlank).toMatch(/^$/); // Validating that the value is empty - let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isEnabled(); - await expect(isDisplayed).toBe(false); -}); - // //SignIn_046 -it("verifyEmailFieldAcceptsLettersWithTwoDots",async()=>{ - const lettersWithDoubleDots=`${SignIn.randomString(2)}.${SignIn.randomString(1)}.${SignIn.randomString(2)}@wevote.us`; - await (await SignIn.emailFieldElement).setValue(lettersWithDoubleDots); - const valueWithTwoDots= await (await SignIn.emailFieldElement).getValue(); - console.log('email value ',valueWithTwoDots); - await expect(valueWithTwoDots).toMatch(/^[a-zA-Z]*\.[a-zA-Z]*\.[a-zA-Z]*@wevote\.us$/); - let isDisplayed= await (await SignIn.sendVerificationEmailBttnElement).isEnabled(); - await expect(isDisplayed).toBe(true); -}); + console.log(`Testing email: ${email}`); + console.log('email length:', email.length); -//SignIn_047 -for(let email of testEmails){ -it('verifyEmailFieldAcceptsCharactersBetween6to254',async()=>{ - - - console.log(`Testing email: ${email}`); - console.log('email length:',email.length); + await (await SignIn.emailFieldElement).setValue(email); + const emailValue = await (await SignIn.emailFieldElement).getValue(); + //console.log('email value ',emailValue); + const len = emailValue.length; + if (len >= 6 && len <= 254) { + await expect(await SignIn.cancelEmailBttnElement).toBeDisplayed(); - await (await SignIn.emailFieldElement).setValue(email); - const emailValue= await (await SignIn.emailFieldElement).getValue(); -//console.log('email value ',emailValue); -const len=emailValue.length; -if(len>=6 && len<=254){ - await expect(await SignIn.cancelEmailBttnElement).toBeDisplayed(); + await expect(await SignIn.sendVerificationEmailBttnElement).toBeEnabled(); + } else { -await expect(await SignIn.sendVerificationEmailBttnElement).toBeEnabled(); -}else{ + await expect(await SignIn.cancelEmailBttnElement).toBeDisplayed(); - await expect(await SignIn.cancelEmailBttnElement).toBeDisplayed(); + await expect(await SignIn.sendVerificationEmailBttnElement).not.toBeEnabled(); -await expect(await SignIn.sendVerificationEmailBttnElement).not.toBeEnabled(); + } + }); } + // //SignIn_052 + it('verifyBackButtonOnVerificationPage', async () => { + const lettersWithDoubleDots = `${SignIn.randomString(2)}.${SignIn.randomString(5)}@wevote.us`; + await (await SignIn.emailFieldElement).setValue(lettersWithDoubleDots); + + await (await SignIn.sendVerificationEmailBttnElement).click(); + await driver.waitUntil(async () => { + return await (await SignIn.codeVerifyElement).getText() === 'Code Verification' + }, { + timeout: 5000, + }); + await (await SignIn.backButtonElement).click(); + await expect(await SignIn.sendVeificationAgainElement).toBeDisplayed(); -}); -} - // //SignIn_052 - it('verifyBackButtonOnVerificationPage',async()=>{ - const lettersWithDoubleDots=`${SignIn.randomString(2)}.${SignIn.randomString(5)}@wevote.us`; - await (await SignIn.emailFieldElement).setValue(lettersWithDoubleDots); - - await (await SignIn.sendVerificationEmailBttnElement).click(); - await driver.waitUntil(async () => { - return await (await SignIn.codeVerifyElement).getText()=== 'Code Verification'}, { - timeout: 5000, - }); - await (await SignIn.backButtonElement).click(); - await expect (await SignIn.sendVeificationAgainElement).toBeDisplayed(); + }); -}); + // //SignIn_054 + it('verifyCancelButtonClearEmailField', async () => { + const email = `${SignIn.randomString(5)}@wevote.us`; + await (await SignIn.emailFieldElement).setValue(email); -// //SignIn_054 -it('verifyCancelButtonClearEmailField',async()=>{ - const email=`${SignIn.randomString(5)}@wevote.us`; - await (await SignIn.emailFieldElement).setValue(email); - - await (await SignIn.cancelEmailBttnElement).click(); - const fieldvalue = await (await SignIn.emailFieldElement).getValue(); - await expect(fieldvalue).toBe(''); - await expect(await SignIn.cancelEmailBttnElement).not.toBeDisplayed(); - await expect(await SignIn.sendVerificationEmailBttnElement).not.toBeDisplayed(); + await (await SignIn.cancelEmailBttnElement).click(); + const fieldvalue = await (await SignIn.emailFieldElement).getValue(); + await expect(fieldvalue).toBe(''); + await expect(await SignIn.cancelEmailBttnElement).not.toBeDisplayed(); + await expect(await SignIn.sendVerificationEmailBttnElement).not.toBeDisplayed(); - //***********Both assertion works same way************************* - //await expect(fieldvalue).toHaveLength(0); - //await expect(fieldvalue).toEqual(''); -//*********************************************************** */ + //***********Both assertion works same way************************* + //await expect(fieldvalue).toHaveLength(0); + //await expect(fieldvalue).toEqual(''); + //*********************************************************** */ -}); + }); }); \ No newline at end of file