I've been trying to catch and throw this error thinking that might be the issue but the test still passes. I am at a loss as to how to catch/throw this (if that is the issue) so the test will fail when the assertion fails.
The Error Msg -
UnhandledPromiseRejectionWarning: AssertionError: expected '25' to equal '2500'
at selectElement.getText.then
...
1 scenario (1 passed)
13 steps (13 passed)
Here is my code Feature Code
Then(/^I verify the below options are correct:$/, async (coverageTable: TableDefinition) => {
async function processArray2(array) {
let ArrayList;
let firstLetterlowerEl;
let actualList;
for (let i = 0; i < array.rows().length; i++) {
ArrayList = Coverage_Defaults[array.rows()[i][0]][array.rows()[i][1]];
firstLetterlowerEl = await array.rows()[i][0].charAt(0).toLowerCase() + array.rows()[i][0].slice(1);
actualList = await coveragesAuto[firstLetterlowerEl].elementId;
await assertions.assertDropDownSelectedValue(actualList,ArrayList);
}
});
The assertion code
public assertDropDownSelectedValue = async (elementId: string, expectedText: string, override?: string) => {
try {
let selectElement = override === 'xpath' ? element(by.xpath(elementId)).$('option:checked') : element(by.id(elementId)).$('option:checked');
await selectElement.getText()
.then((text: any) => expect(text).to.equal(expectedText)).catch(Err => {throw Err.stack})
} catch (Err) {
if (Err instanceof error.NoSuchElementError) {
log.error(`${elementId} Element not found error \n ${Err.stack}`);
throw Err.stack;
} else if (Err instanceof error.ElementNotSelectableError) {
log.error(Err.stack);
throw Err.stack;
} else {
log.error(`Dropdown selected option does NOT match with expected text - elementId passed : ${elementId}`);
throw Err;
}
}
}