mardi 17 décembre 2019

TestCafe: web application with dynamic ids

i'm new user of TestCafe, i have a problem: the web application that i'm testing has elements with dynamic ids. So when I run my test i have an error because the Selector not find the element in exam. How to resolve this problem? can you help me?

    import { Selector } from 'testcafe';

    fixture `test1212`
        .page `192.168.1.26:801/Login.aspx?ReturnUrl=%2f`;

    test('New Test 1', async t => {
        await t
            .typeText(Selector('#Logon_v0_38054418_MainLayoutEdit_xaf_l13_xaf_dviUserName_Edit_I'), 'TMZ\\rossimarta')
            .pressKey('tab')
            .typeText(Selector('#Logon_v0_38054418_MainLayoutEdit_xaf_l17_xaf_dviPassword_Edit_I'), 'gipstech02')
            .click(Selector('span').withText('Accedi'));
    });

the Selector's parameter is id of the element in exam, but this id change for each access of the page. So when i run my test i have a error.

thanks guys!

Aucun commentaire:

Enregistrer un commentaire