Skip to content

Commit ef2a66f

Browse files
authored
Merge pull request #4731 from nadiavaida/Nadia_WV_2678_V1.0
WV_2678_V1.2 match search results on party name as well.
2 parents 9b00973 + cb3c29f commit ef2a66f

2 files changed

Lines changed: 25 additions & 15 deletions

File tree

tests/browserstack_automation/specs/CandidatesPage.browser.js

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ beforeEach(async () => {
1616
await CandidatesPage.load();
1717
await driver.pause(waitTime);
1818
// Below line to be commented out once defect #WV-943 is fixed.
19-
// await CandidatesPage.stateSelect.selectByVisibleText('Hawaii');
19+
// await CandidatesPage.stateSelect.selectByVisibleText('Hawaii');
2020
//await driver.pause(waitTime);
2121
});
2222

@@ -353,7 +353,7 @@ describe('Candidates PageBrowser', () => {
353353
}
354354
});
355355

356-
// Candidates_018
356+
// Candidates_018
357357
it('verifyLikeCandidateClick @WV-1073', async () => {
358358
const stateNameRandomTC10 = readTestDataStates('random', 1)[0];
359359
console.log(`Running verifyLikeCandidateClick using state ${stateNameRandomTC10}`);
@@ -438,9 +438,9 @@ describe('Candidates PageBrowser', () => {
438438
});
439439

440440
// Candidates_023-Candidates_030
441-
const searchText=readSearchText();
441+
const searchText = readSearchText();
442442
searchText.forEach(({ text, runType }) => {
443-
it(`verifyCandidateSearchByNameOrOffice for ${text} with ${runType}`, async () => {
443+
it(`verifyCandidateSearchByNameOrOfficeOrParty for ${text} with ${runType}`, async () => {
444444
console.log(` *** ***** Running verifySearchText using name: ${text}, state: ${runType}`);
445445
const stateNameRandomTC23 = readTestDataStates('random', 1)[0];
446446
await CandidatesPage.searchBar.click();
@@ -453,7 +453,7 @@ describe('Candidates PageBrowser', () => {
453453
await driver.pause(waitTime);
454454
}
455455
const candidateCards = await CandidatesPage.candidateSearchList;
456-
console.log(`Total cards: ${candidateCards.length}`)
456+
console.log(`Total cards: ${candidateCards.length}`);
457457
for (let i = 0; i < candidateCards.length; i++) {
458458
const card = candidateCards[i];
459459
await driver.waitUntil(async () => !(await card.getAttribute('id')).includes('Loading'), {
@@ -463,23 +463,33 @@ describe('Candidates PageBrowser', () => {
463463
const cardId = await card.getAttribute('id');
464464
const candidateNameDisplayed = (await CandidatesPage.getCandidateCardCandidateName(cardId));
465465
const officeNameDisplayed = (await CandidatesPage.getCandidateCardOffice(cardId));
466+
const partyNameDisplayed = (await CandidatesPage.getCandidateCardPartyName(cardId));
466467

467468
console.log(`Candidate Name: ${candidateNameDisplayed}`);
468469
console.log(`Candidate Office: ${officeNameDisplayed}`);
469-
if (runType === 'stateSelected'){
470-
const expectedStateValue=['National'.toUpperCase(),stateNameRandomTC23.toUpperCase()];
471-
const stateNameDisplayed= (await CandidatesPage.getCandidateCardState(cardId)).toUpperCase();
470+
console.log(`Candidate Party: ${partyNameDisplayed}`);
471+
if (runType === 'stateSelected') {
472+
const expectedStateValue = ['National'.toUpperCase(), stateNameRandomTC23.toUpperCase()];
473+
const stateNameDisplayed = (await CandidatesPage.getCandidateCardState(cardId)).toUpperCase();
472474
console.log(`Candidate State: ${stateNameDisplayed}`);
473-
await` expect(expectedStateValue).toContain(stateNameDisplayed);`
475+
await expect(expectedStateValue).toContain(stateNameDisplayed);
474476
}
475477
try {
476478
await expect(candidateNameDisplayed.toLowerCase()).toContain(text.toLowerCase());
479+
console.log(`Candidate Name contains searched text: "${text}" for Candidate: ${candidateNameDisplayed}`);
477480
} catch {
478-
await console.log(`Candidate Name did not match the searched text: << ${text} >>, checking Office Name instead...`);
481+
console.log(`Candidate Name did not match the searched text: << ${text} >>, checking Office Name instead...`);
479482
try {
480483
await expect(officeNameDisplayed.toLowerCase()).toContain(text.toLowerCase());
484+
console.log(`Office Name contains searched text: "${text}" for Candidate: ${candidateNameDisplayed}`);
481485
} catch {
482-
throw new Error(`Neither candidateName nor officeName matched searched text: "${text}" for Candidate: ${candidateNameDisplayed}`);
486+
console.log(`Office Name did not match the searched text: << ${text} >>, checking Party Name instead...`);
487+
try {
488+
await expect(partyNameDisplayed.toLowerCase()).toContain(text.toLowerCase());
489+
console.log(`Party Name contains searched text: "${text}" for Candidate: ${candidateNameDisplayed}`);
490+
} catch {
491+
throw new Error(`Neither candidateName nor officeName nor partyName matched searched text: "${text}" for Candidate: ${candidateNameDisplayed}`);
492+
}
483493
}
484494
}
485495
}
@@ -532,14 +542,14 @@ describe('Candidates PageBrowser', () => {
532542
allSearch.push(searchText.toLowerCase());
533543
allSearch.push(searchText.toUpperCase());
534544
allSearch.push(searchText[0].toUpperCase()+searchText.slice(1));
535-
}
545+
}
536546
const states = ['stateNotSelected', 'stateSelected'];
537547
const combinations = [];
538548
for (const text of allSearch) {
539549
for (const runType of states) {
540-
combinations.push({ text, runType });
541-
}
550+
combinations.push({ text, runType });
542551
}
552+
}
543553

544554
console.log("Running tests for test data combinations:");
545555
console.log(combinations);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[
22
{
3-
"SearchText":["Abraham Lincoln","Stein"]
3+
"SearchText":["Abraham Lincoln","Carolin"]
44
}
55
]

0 commit comments

Comments
 (0)