Skip to content

Commit

Permalink
fix(screenshots)(AgeGroupsTimeline)(customChart):.
Browse files Browse the repository at this point in the history
TypeError: "Cannot read property '0' of undefined"
  • Loading branch information
jalezi committed May 4, 2021
1 parent 51dc0fb commit 2aea44a
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions screenshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,25 @@ const loopAndShowTooltip = async (series, index, options) => {
const selectorsArray = await Promise.all(
series.map(async item => await item.$$(options.selector))
);
const filtered = selectorsArray.filter(
item => item.length === options.length
);
const filtered = selectorsArray.filter(item => item.length > options.length);

if (filtered.length === 0) {
throw new Error(
`No filtered array. [series] length: ${
series.length
}, [index]: ${index}, [options]: ${options.toString()}`
);
}

const buttons = filtered[0];
if (buttons.length - 1 < index) {
throw new Error(
`Can not find index; array length: ${buttons.length}, [index]: ${index}`
);
}

filtered.length > 0 && (await elementHandleClick(filtered[0][index]));
return filtered[0][index];
await elementHandleClick(buttons[index]);
return buttons[index];
};

CHART = {
Expand Down

0 comments on commit 2aea44a

Please sign in to comment.