@intuned/browser-dev 0.1.6-dev.0 → 0.1.6-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -20,12 +20,7 @@ const clickButtonAndWaitInternal = async (page, buttonLocator, clickDelay) => {
|
|
|
20
20
|
});
|
|
21
21
|
await new Promise(resolve => setTimeout(resolve, clickDelay * 1000));
|
|
22
22
|
};
|
|
23
|
-
const
|
|
24
|
-
const {
|
|
25
|
-
page,
|
|
26
|
-
buttonLocator,
|
|
27
|
-
clickDelay = 0.5
|
|
28
|
-
} = input;
|
|
23
|
+
const clickButtonWithNetworkWait = async (page, buttonLocator, clickDelay) => {
|
|
29
24
|
await (0, _withNetworkSettledWait.withNetworkSettledWait)(async () => {
|
|
30
25
|
await clickButtonAndWaitInternal(page, buttonLocator, clickDelay);
|
|
31
26
|
}, {
|
|
@@ -34,6 +29,14 @@ const clickButtonAndWait = async input => {
|
|
|
34
29
|
timeoutInMs: 10000
|
|
35
30
|
});
|
|
36
31
|
};
|
|
32
|
+
const clickButtonAndWait = async input => {
|
|
33
|
+
const {
|
|
34
|
+
page,
|
|
35
|
+
buttonLocator,
|
|
36
|
+
clickDelay = 0.5
|
|
37
|
+
} = input;
|
|
38
|
+
await clickButtonWithNetworkWait(page, buttonLocator, clickDelay);
|
|
39
|
+
};
|
|
37
40
|
exports.clickButtonAndWait = clickButtonAndWait;
|
|
38
41
|
const clickUntilExhausted = async input => {
|
|
39
42
|
const {
|
|
@@ -45,41 +48,35 @@ const clickUntilExhausted = async input => {
|
|
|
45
48
|
clickDelay = 0.5,
|
|
46
49
|
noChangeThreshold = 0
|
|
47
50
|
} = input;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
let prevState = null;
|
|
52
|
+
if (containerLocator) {
|
|
53
|
+
prevState = await getContainerState(containerLocator);
|
|
54
|
+
_Logger.logger.info(`Initial container state: ${prevState}`);
|
|
55
|
+
}
|
|
56
|
+
const buttonCount = await buttonLocator.count();
|
|
57
|
+
_Logger.logger.info(`Button matches: ${buttonCount}`);
|
|
58
|
+
for (let i = 0; i < maxClicks; i++) {
|
|
59
|
+
heartbeat === null || heartbeat === void 0 || heartbeat();
|
|
60
|
+
const isVisible = await buttonLocator.isVisible();
|
|
61
|
+
if (!isVisible) {
|
|
62
|
+
_Logger.logger.info("Button not visible, stopping.");
|
|
63
|
+
break;
|
|
53
64
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
_Logger.logger.info("Button not enabled, stopping.");
|
|
65
|
+
const isEnabled = await buttonLocator.isEnabled();
|
|
66
|
+
if (!isEnabled) {
|
|
67
|
+
_Logger.logger.info("Button not enabled, stopping.");
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
await clickButtonWithNetworkWait(page, buttonLocator, clickDelay);
|
|
71
|
+
if (containerLocator) {
|
|
72
|
+
const currentState = await getContainerState(containerLocator);
|
|
73
|
+
_Logger.logger.info(`Current container state: ${currentState}`);
|
|
74
|
+
if (prevState !== null && currentState - prevState <= noChangeThreshold) {
|
|
75
|
+
_Logger.logger.info(`No significant change in container state: ${currentState} (previous: ${prevState})`);
|
|
66
76
|
break;
|
|
67
77
|
}
|
|
68
|
-
|
|
69
|
-
if (containerLocator) {
|
|
70
|
-
const currentState = await getContainerState(containerLocator);
|
|
71
|
-
_Logger.logger.info(`Current container state: ${currentState}`);
|
|
72
|
-
if (prevState !== null && currentState - prevState <= noChangeThreshold) {
|
|
73
|
-
_Logger.logger.info(`No significant change in container state: ${currentState} (previous: ${prevState})`);
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
prevState = currentState;
|
|
77
|
-
}
|
|
78
|
+
prevState = currentState;
|
|
78
79
|
}
|
|
79
|
-
}
|
|
80
|
-
page,
|
|
81
|
-
maxInflightRequests: 0,
|
|
82
|
-
timeoutInMs: 30000
|
|
83
|
-
});
|
|
80
|
+
}
|
|
84
81
|
};
|
|
85
82
|
exports.clickUntilExhausted = clickUntilExhausted;
|