-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathtest-navigation.js
More file actions
executable file
·57 lines (42 loc) · 1.62 KB
/
test-navigation.js
File metadata and controls
executable file
·57 lines (42 loc) · 1.62 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
49
50
51
52
53
54
55
56
57
#!/usr/bin/env node
import { FirefoxDevTools } from './dist/index.js';
async function test() {
console.log('=== Test: Start Firefox and navigate ===\n');
const firefox = new FirefoxDevTools({
headless: false,
firefoxPath: process.env.HOME + '/firefox/firefox',
});
await firefox.connect();
console.log('✓ Firefox started');
await firefox.navigate('https://example.com');
console.log('✓ Navigated to example.com');
await new Promise(resolve => setTimeout(resolve, 2000));
await firefox.navigate('https://mozilla.org');
console.log('✓ Navigated to mozilla.org');
await new Promise(resolve => setTimeout(resolve, 2000));
await firefox.refreshTabs();
const tabs = firefox.getTabs();
console.log(`✓ Listed tabs: ${tabs.length} tab(s)`);
if (tabs.length > 0) {
console.log(` Current URL: ${tabs[0].url}`);
console.log(` Current title: ${tabs[0].title || 'N/A'}`);
}
await new Promise(resolve => setTimeout(resolve, 2000));
await firefox.navigate('https://www.w3.org');
console.log('✓ Navigated to w3.org');
await new Promise(resolve => setTimeout(resolve, 2000));
await firefox.refreshTabs();
const tabsAfter = firefox.getTabs();
console.log(`✓ Listed tabs again: ${tabsAfter.length} tab(s)`);
if (tabsAfter.length > 0) {
console.log(` Current URL: ${tabsAfter[0].url}`);
}
await firefox.close();
console.log('\n✓ Basic navigation tests passed!');
console.log('\nNote: To test restart_firefox with logs, use the MCP inspector:');
console.log(' npm run inspector');
}
test().catch(err => {
console.error('\nTest failed:', err);
process.exit(1);
});