MCPcopy Create free account
hub / github.com/Rello/analytics / clickFirst

Function clickFirst

tests/playwright/common.js:53–79  ·  view source on GitHub ↗
(page, selectors, label, options = {})

Source from the content-addressed store, hash-verified

51}
52
53async function clickFirst(page, selectors, label, options = {}) {
54 const throwOnMissing = options.throwOnMissing !== false;
55 const timeout = options.timeout || 8000;
56 const waitAfterMs = options.waitAfterMs || 300;
57
58 for (const selector of selectors) {
59 const locator = page.locator(selector).first();
60 if (!(await locator.count())) {
61 continue;
62 }
63 try {
64 await locator.click({ timeout });
65 await waitForIdle(page);
66 if (waitAfterMs > 0) {
67 await page.waitForTimeout(waitAfterMs);
68 }
69 return { clicked: true, selector };
70 } catch (error) {
71 // try fallback selector
72 }
73 }
74
75 if (throwOnMissing) {
76 throw new Error(`Could not click ${label}. Selectors: ${selectors.join(', ')}`);
77 }
78 return { clicked: false, selector: null };
79}
80
81async function fillRequired(page, selector, value, label) {
82 const locator = page.locator(selector).first();

Callers 15

openTranslateMenuFunction · 0.85
21_filter.jsFile · 0.85
22_drilldown.jsFile · 0.85
29_group_top_n.jsFile · 0.85
unlockPublicShareFunction · 0.85
ensureAnalyticsLoadedFunction · 0.85

Calls 2

waitForIdleFunction · 0.85
firstMethod · 0.80

Tested by

no test coverage detected