I'm setting up a testing suite with Testcafe that is able to check the interface of multiple web apps made with the XAF framework. Problem is, that some buttons on the same place with the same functionality do have different names (i.e. "Sortierung aufheben" and "Sortierung entfernen"). Now I'd like to give Testcafe these two options to choose and let it use the one needed in the test.
I'm writing my test in Typescript 3.5 using VSC and Chrome to run the tests.
Testcafe runs my assertion neatly when I only add one of the options on the withText()
selector. If I try adding two in an array (see code below) it starts checking the first one first - which in case of one website is the wrong one - and fails.
My testing is working like this:
// Functions_Library.ts
FindListMultipleElements(propertyName, elementNames: string[]): Selector {
var selector = "[class^='dxm-"+propertyName+"']";
for (var i=0; i < elementNames.length; i++) {
var element = Selector('body').find(selector).withText(elementNames[i]);
if (element != null) {
return element;
}
}
// all_tests.ts
listViews.forEach(listView => {
test(`${moduleName} - ${listView.navbarItem} - ColumnCheck Tests`, async t => {
await t
.click(lib.FindListMultipleElements('content', ['Sortierung aufheben','Sortierung entfernen']))
});
});
I would like to either have Testcafe skip the misfitting parameter or only choose the right one. Is this possible in some kind of way?