jeudi 16 janvier 2020

testcafe - CAS authentication

New to TestCafe. Got some simple example tests working easily. However, I wasn't able to find any examples of features that would seem to allow me to log in to my application via a CAS authentication page.

This code works to find the login button on the login page and click it.

fixture`VRT`
    .page `http://myapp.com/login/`;

test('Find Login button', async t => {
    const input = Selector('input.btn');

    await t.click(input);
});

And this would work to type in the username and password on the login page:

test('Login using CAS', async t => {
     await t
     .expect("#username").exists
     .typeText('#username', 'myuser')
     .typeText('#password', '***')
     .click('#submit');
});

But the problem is that there seems to be no way to continue from one test to another. So I can't go from the first test that opens the login page, to the next test that enters the credentials. It seems like, for TestCafe, every test has to specify its own page.

If I try to go to the CAS login page directly, by specifying it as the fixture "page", TestCafe fails to open the page, I think because the URL is extremely long.

Thanks for any suggestions.

Aucun commentaire:

Enregistrer un commentaire