I have the following DOM tree (simplified)
<div class=row-0>...</div>
<div class=row-1>
<div class=container>
<div class=panel>...</div>
</div>
</div>
<div class=row-2>...</div>
<div class=row-3>
<div class=container>
<div class=panel>...</div>
<div class=drawer>...</div>
</div>
</div>
<div class=row-4>...</div>
As you can see, all elements have a panel class=panel
but not all elements have a drawer class=drawer
. I am iterating through the elements as follows:
const events = Selector('[class^="row-"]');
const eventCount = await events.count;
for (let i = 0; i < eventCount; i++) {
const event = await events.nth(i);
// Here's where I want to check if the event (class=row-x) has a child element class=drawer
const drawer = await Selector(event).child('class["drawer"]')
if (await drawer.exists) {
console.log('Found drawer')
}
}
I can successfully iterate through all the rows, but I cannot detect if a certain event has a drawer. I tried to follow the logic from this answer.
How can I perform this logic?
Aucun commentaire:
Enregistrer un commentaire