lundi 13 juillet 2020

Testcafe Checking if DOM Element not present

I am trying to get a hang of Test Cafe but currently I am stuck. I have a webapp I want to test starting at the login and ending with a logout. When I login with wrong credentials I display a DOM Element with the id = errorMsg.

With Test Cafe I want to check if the DOM Element is present or not.

This is my test script, the basic-page-model.js is a collection of all DOM elements ids used in the test.

import Page from './basic-page-model';
import { Selector } from 'testcafe';

fixture `Full Test Run of Main Features Role User`
    .page `https://localhost:8443/login.jsp`;

const page = new Page();

const errorMessage= Selector('#errorMsg');
test('login test', async t => {
        
        await t
            .typeText(page.nameInput, 'user')
            .typeText(page.passInput, 'user') //correct password -> password 
            .click(page.login)
            .expect(errorMessage.exists).notOk();

});

It doesn't matter if the login will fail or not it always returns test passed. Can somebody please point me in the right direction?

Aucun commentaire:

Enregistrer un commentaire