2020-10-31

TestCafe loop over elements and check if class exists within Set

I have a table with a column of icons. Each Icon has a class of "test" and then "test" + [some rating]. The rating could be A, B, C, XX, YY. I'd like to select the group of icons and loop over them, pop off the last class (the one with the rating) and then expect that my Set of classConsts contains the class in question. I've done a bunch of research but can only find examples of interacting with each of the elements, I'm not sure what I'm doing wrong when trying to check the classes on each instead. Any help is appreciated, thanks.

The below code blows up when i call mrArray.nth saying it's not a function (sorry its a bit messy, had to change some variable names around)

test('Sers are verified', async t => {
    const IconArr = Selector('#testtable .test');
    var count = await IconArr().count;
    var myArray = await IconArr();

    const classConsts = ["testClassA", "testClassB", "testClassC", "testClassXX", "testClassYY"]

    let mySet = new Set(classConsts);

    for(let i = 1; i <= count; i++){
        mySet.has(myArray.nth(i).classNames.pop());
        await t.expect(mySet.has(i.classNames.pop())).eql(true)
    
    };
});


from Recent Questions - Stack Overflow https://ift.tt/37RxFGO
https://ift.tt/eA8V8J

No comments:

Post a Comment