lundi 21 septembre 2020

How can I log into my web app, then read through the records of my data.json file using TestCafe

I've googled and I can find how to loop through my data file. Apparently you run a test for each record of data.

I would like to have my single test log in, then cycle through each 'record' or item of the data file. The data is a series of searches in our app. So, the test would login and assert logged in then run those searches...

test('searches', async t => {
await t
    // Log in...   
    .typeText('input[id="login-name"]', 'alittle')
    .typeText('input[id="login-password"]', 'aaa')
    .click('button[id="signin-button"')
    .expect(Selector('span[id="logged-in-user"]').innerText).contains('Hal')  

    // At this point the app is ready to run through the searches doing this...
    // forEach item in my data...
        .typeText('input[id="simplecriteria"]', data.criteria)
        .click('button[class="search-button"]')
        .expect(Selector('div[class="mat-paginator-range-label"]').innerText).contains(data.srchResult)      
});

Aucun commentaire:

Enregistrer un commentaire