@stablyai/internal-playwright-core 0.1.0 → 0.1.2
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.
package/lib/server/frames.js
CHANGED
|
@@ -923,7 +923,7 @@ class Frame extends import_instrumentation.SdkObject {
|
|
|
923
923
|
try {
|
|
924
924
|
return await this._retryWithProgressIfNotConnected(progress, selector, strict, performActionPreChecks, action);
|
|
925
925
|
} catch (error) {
|
|
926
|
-
const isAutoHealEnabled = autoHeal ?? (0, import_healingService.
|
|
926
|
+
const isAutoHealEnabled = autoHeal ?? (0, import_healingService.isLocatorHealingEnabled)();
|
|
927
927
|
if (!isAutoHealEnabled)
|
|
928
928
|
throw error;
|
|
929
929
|
const healedResult = await this._attemptHealingRetry(
|
|
@@ -21,8 +21,11 @@ __export(healingService_exports, {
|
|
|
21
21
|
attemptAutohealLocator: () => attemptAutohealLocator,
|
|
22
22
|
attemptToHaveScreenshotHealing: () => attemptToHaveScreenshotHealing,
|
|
23
23
|
getHealingConfig: () => getHealingConfig,
|
|
24
|
+
getLocatorHealingConfig: () => getLocatorHealingConfig,
|
|
25
|
+
getScreenshotHealingConfig: () => getScreenshotHealingConfig,
|
|
24
26
|
healLocator: () => healLocator,
|
|
25
|
-
|
|
27
|
+
isLocatorHealingEnabled: () => isLocatorHealingEnabled,
|
|
28
|
+
isScreenshotHealingEnabled: () => isScreenshotHealingEnabled,
|
|
26
29
|
setHealingConfig: () => setHealingConfig
|
|
27
30
|
});
|
|
28
31
|
module.exports = __toCommonJS(healingService_exports);
|
|
@@ -44,8 +47,31 @@ function setHealingConfig(config) {
|
|
|
44
47
|
function getHealingConfig() {
|
|
45
48
|
return { ...globalHealingConfig };
|
|
46
49
|
}
|
|
47
|
-
function
|
|
48
|
-
|
|
50
|
+
function getLocatorHealingConfig() {
|
|
51
|
+
const globalConfig = getHealingConfig();
|
|
52
|
+
const locatorConfig = globalConfig.locators || {};
|
|
53
|
+
return {
|
|
54
|
+
enabled: locatorConfig.enabled ?? globalConfig.enabled,
|
|
55
|
+
model: locatorConfig.model ?? globalConfig.model,
|
|
56
|
+
timeout: locatorConfig.timeout ?? globalConfig.timeout
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function getScreenshotHealingConfig() {
|
|
60
|
+
const globalConfig = getHealingConfig();
|
|
61
|
+
const screenshotConfig = globalConfig.screenshots || {};
|
|
62
|
+
return {
|
|
63
|
+
enabled: screenshotConfig.enabled ?? globalConfig.enabled,
|
|
64
|
+
model: screenshotConfig.model ?? globalConfig.model,
|
|
65
|
+
timeout: screenshotConfig.timeout ?? globalConfig.timeout
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function isLocatorHealingEnabled() {
|
|
69
|
+
const config = getLocatorHealingConfig();
|
|
70
|
+
return config.enabled;
|
|
71
|
+
}
|
|
72
|
+
function isScreenshotHealingEnabled() {
|
|
73
|
+
const config = getScreenshotHealingConfig();
|
|
74
|
+
return config.enabled;
|
|
49
75
|
}
|
|
50
76
|
async function healLocator({
|
|
51
77
|
frame,
|
|
@@ -59,7 +85,7 @@ async function healLocator({
|
|
|
59
85
|
message: "No description provided for healing. Use .describe() to enable auto-healing."
|
|
60
86
|
};
|
|
61
87
|
}
|
|
62
|
-
const config =
|
|
88
|
+
const config = getLocatorHealingConfig();
|
|
63
89
|
try {
|
|
64
90
|
const screenshot = await (0, import_screenshotFrame.captureScreenshot)(frame);
|
|
65
91
|
const aiResponse = await (0, import_stablyApiCaller.callAiToAutohealLocator)({
|
|
@@ -178,7 +204,7 @@ async function healToHaveScreenshot({
|
|
|
178
204
|
actualScreenshot,
|
|
179
205
|
expectedScreenshot
|
|
180
206
|
}) {
|
|
181
|
-
const config =
|
|
207
|
+
const config = getScreenshotHealingConfig();
|
|
182
208
|
try {
|
|
183
209
|
return await (0, import_stablyApiCaller2.callAiToAutohealScreenshot)({
|
|
184
210
|
actualScreenshot,
|
|
@@ -196,21 +222,15 @@ async function attemptToHaveScreenshotHealing({
|
|
|
196
222
|
actualScreenshot,
|
|
197
223
|
expectedScreenshot
|
|
198
224
|
}) {
|
|
199
|
-
const
|
|
225
|
+
const healingResult = await healToHaveScreenshot({
|
|
200
226
|
actualScreenshot,
|
|
201
227
|
expectedScreenshot
|
|
202
228
|
});
|
|
203
|
-
await saveToHaveScreenshotAutohealResult(
|
|
204
|
-
return result;
|
|
229
|
+
await saveToHaveScreenshotAutohealResult(healingResult);
|
|
230
|
+
return healingResult.result;
|
|
205
231
|
}
|
|
206
|
-
async function saveToHaveScreenshotAutohealResult({
|
|
207
|
-
result,
|
|
208
|
-
reason
|
|
209
|
-
}) {
|
|
210
|
-
const healingDataBody = JSON.stringify({
|
|
211
|
-
reason,
|
|
212
|
-
result
|
|
213
|
-
}, null, 2);
|
|
232
|
+
async function saveToHaveScreenshotAutohealResult(result) {
|
|
233
|
+
const healingDataBody = JSON.stringify(result, null, 2);
|
|
214
234
|
const stepInfoOrTestInfo = (0, import_stepContext.getCurrentStepInfo)() ?? (0, import_globals.currentTestInfo)();
|
|
215
235
|
stepInfoOrTestInfo?.attach("toHaveScreenshot-autoheal-results", {
|
|
216
236
|
body: healingDataBody,
|
|
@@ -222,7 +242,10 @@ async function saveToHaveScreenshotAutohealResult({
|
|
|
222
242
|
attemptAutohealLocator,
|
|
223
243
|
attemptToHaveScreenshotHealing,
|
|
224
244
|
getHealingConfig,
|
|
245
|
+
getLocatorHealingConfig,
|
|
246
|
+
getScreenshotHealingConfig,
|
|
225
247
|
healLocator,
|
|
226
|
-
|
|
248
|
+
isLocatorHealingEnabled,
|
|
249
|
+
isScreenshotHealingEnabled,
|
|
227
250
|
setHealingConfig
|
|
228
251
|
});
|