-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathform-fill-screenshot.ts
More file actions
48 lines (39 loc) · 1.27 KB
/
form-fill-screenshot.ts
File metadata and controls
48 lines (39 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Form Filling and Screenshots Example
*
* This example demonstrates:
* - Filling form inputs with type() action
* - Automatic input type detection
* - Taking full-page and viewport screenshots
*/
import 'dotenv/config';
import { Extract } from 'maxun-sdk';
async function main() {
const extractor = new Extract({
apiKey: process.env.MAXUN_API_KEY!,
baseUrl: process.env.MAXUN_BASE_URL
});
try {
const robot = await extractor
.create('Form Fill Demo')
.navigate('https://practice.expandtesting.com/inputs')
.type('#input-text', 'John Doe')
.type('#input-number', '42')
.type('#input-password', 'SecurePassword123')
.type('#input-date', '15-08-2024')
.captureScreenshot('Full Page', { fullPage: true })
.captureScreenshot('Viewport', { fullPage: false });
console.log(`Robot created: ${robot.id}`);
const result = await robot.run();
console.log('\nForm filling completed');
console.log('Screenshots captured:', Object.keys(result.data.binaryOutput || {}).length);
} catch (error: any) {
console.error('Error:', error.message);
process.exit(1);
}
}
if (!process.env.MAXUN_API_KEY) {
console.error('Error: MAXUN_API_KEY environment variable is required');
process.exit(1);
}
main();