@probolabs/playwright 0.4.8 → 0.4.9
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/dist/actions.d.ts +24 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +241 -0
- package/dist/api-client.d.ts +32 -0
- package/dist/api-client.d.ts.map +1 -0
- package/dist/api-client.js +125 -0
- package/dist/highlight.d.ts +28 -0
- package/dist/highlight.d.ts.map +1 -0
- package/dist/highlight.js +79 -0
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +67 -42
- package/dist/index.js.map +1 -1
- package/dist/probo-playwright.esm.js +63 -0
- package/dist/probo-playwright.umd.js +644 -0
- package/dist/src/actions.d.ts +18 -0
- package/dist/src/api-client.d.ts +13 -0
- package/dist/src/highlight.d.ts +28 -0
- package/dist/src/index.d.ts +20 -0
- package/dist/src/utils.d.ts +20 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/actions.d.ts.map +1 -1
- package/dist/types/api-client.d.ts.map +1 -1
- package/dist/types/highlight.d.ts.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/utils.d.ts +21 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +39 -0
- package/package.json +2 -2
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
|
|
4
|
+
const ElementTag = {
|
|
5
|
+
CLICKABLE: "CLICKABLE", // button, link, toggle switch, checkbox, radio, dropdowns, clickable divs
|
|
6
|
+
FILLABLE: "FILLABLE", // input, textarea content_editable, date picker??
|
|
7
|
+
SELECTABLE: "SELECTABLE", // select
|
|
8
|
+
NON_INTERACTIVE_ELEMENT: 'NON_INTERACTIVE_ELEMENT',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Import ElementTag from constants
|
|
12
|
+
// Read the UMD bundle at build time
|
|
13
|
+
const highlighterCode = readFileSync(join(__dirname, '../../probo-highlighter/dist/probolabs.umd.js'), 'utf8');
|
|
14
|
+
class Probo {
|
|
15
|
+
constructor(token, apiUrl) {
|
|
16
|
+
this.token = token;
|
|
17
|
+
this.apiUrl = apiUrl;
|
|
18
|
+
console.log('Probo constructor', this.token, this.apiUrl);
|
|
19
|
+
}
|
|
20
|
+
setupConsoleLogs(page) {
|
|
21
|
+
{
|
|
22
|
+
page.on('console', msg => {
|
|
23
|
+
const type = msg.type();
|
|
24
|
+
const text = msg.text();
|
|
25
|
+
console.log(`BROWSER CONSOLE [${type}]: ${text}`);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async ensureHighlighterScript(page) {
|
|
30
|
+
this.setupConsoleLogs(page);
|
|
31
|
+
const scriptExists = await page.evaluate(`typeof window.ProboLabs?.highlight?.execute === 'function'`);
|
|
32
|
+
if (!scriptExists) {
|
|
33
|
+
console.log('DEBUG: Injecting highlighter script...');
|
|
34
|
+
await page.evaluate(highlighterCode);
|
|
35
|
+
// Verify the script was injected correctly
|
|
36
|
+
const verified = await page.evaluate(`
|
|
37
|
+
console.log('ProboLabs global:', window.ProboLabs);
|
|
38
|
+
typeof window.ProboLabs?.highlight?.execute === 'function'
|
|
39
|
+
`);
|
|
40
|
+
console.log('DEBUG: Script injection verified:', verified);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async highlightElements(page, elementTag) {
|
|
44
|
+
console.log('highlightElements called with:', elementTag);
|
|
45
|
+
await this.ensureHighlighterScript(page);
|
|
46
|
+
// Execute the highlight function and await its result
|
|
47
|
+
const result = await page.evaluate(async (tag) => {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
console.log('Browser: Starting highlight execution with tag:', tag);
|
|
50
|
+
if (!((_b = (_a = window.ProboLabs) === null || _a === void 0 ? void 0 : _a.highlight) === null || _b === void 0 ? void 0 : _b.execute)) {
|
|
51
|
+
console.error('Browser: ProboLabs.highlight.execute is not available!');
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const elements = await window.ProboLabs.highlight.execute([tag]);
|
|
55
|
+
console.log('Browser: Found elements:', elements);
|
|
56
|
+
return elements;
|
|
57
|
+
}, elementTag);
|
|
58
|
+
console.log('Highlight result:', result);
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { ElementTag, Probo };
|