not able to assert element value webdriverIO

187 Views Asked by At

I am trying to assert one element value by using the following code:

async  user_verify_loan_term() {
    await chaiExpect(element.getAttribute("value")==="3")
}

The assertion is not working. The expected value should be 30; but the test passes. How to fix it?

1

There are 1 best solutions below

0
Дмитрий Шатов On

Chai doesn't know how to compare values ​​in this way. This equality (===) is used in JS itself, but not in Chai. Your code should look something like this:

const expectChai = require('chai').expect;

describe('title', async () => { 
    it('title', async () => {
        const element = await $('form')
        const attr = await (await element).getAttribute('method')
        await expectChai(await attr).to.equal("3");
    });
});

If atr: string = "3" then it will be true.