mardi 28 avril 2020

Puppeteer & Cucumber Selecting one class (from 48 with same class) and clicking on it

I have this problem since yesterday and can't figuered out how to solve it. The problem is that I have 48 buttons with same class (the childs are the same too). Tried using xpath, other classes inside but nothing work.

It work creating an array with all buttons and then pressing on it with "button[number]" but I don't know exactly which number is every button. The last thing that I did was create this loop to check the page by clicking on every single button (may be redirected to the correct one) but didn't work. Maybe I wrote something wrong.

When('I press the Users tab', async function () {
const tabToPress = await scope.page.$$('.ng-star-inserted');
var numberToPress;
for (var index = 0; index < tabToPress.length; index++) {
    await tabToPress[index].click();
    const desiredPage = `https://3.0.testing.azavista.com/users/users`;
    const currentPage = await scope.page.url();
    if (currentPage === desiredPage) {
        numberToPress = index
    }
};
await tabToPress[numberToPress].click();
await scope.page.waitFor(1000);

Aucun commentaire:

Enregistrer un commentaire