|
| 1 | +--- |
| 2 | +sidebar_position: 7 |
| 3 | +--- |
| 4 | + |
| 5 | +# System Browser Detection |
| 6 | + |
| 7 | +MyCoder includes a system browser detection feature that allows it to use your existing installed browsers instead of requiring Playwright's bundled browsers. This is especially useful when MyCoder is installed globally via npm. |
| 8 | + |
| 9 | +## How It Works |
| 10 | + |
| 11 | +When you start a browser session in MyCoder, the system will: |
| 12 | + |
| 13 | +1. Detect available browsers on your system (Chrome, Edge, Firefox, etc.) |
| 14 | +2. Select the most appropriate browser based on your configuration preferences |
| 15 | +3. Launch the browser using Playwright's `executablePath` option |
| 16 | +4. Fall back to Playwright's bundled browsers if no system browser is found |
| 17 | + |
| 18 | +This process happens automatically and is designed to be seamless for the user. |
| 19 | + |
| 20 | +## Supported Browsers |
| 21 | + |
| 22 | +MyCoder can detect and use the following browsers: |
| 23 | + |
| 24 | +### Windows |
| 25 | +- Google Chrome |
| 26 | +- Microsoft Edge |
| 27 | +- Mozilla Firefox |
| 28 | + |
| 29 | +### macOS |
| 30 | +- Google Chrome |
| 31 | +- Google Chrome Canary |
| 32 | +- Microsoft Edge |
| 33 | +- Mozilla Firefox |
| 34 | +- Firefox Developer Edition |
| 35 | +- Firefox Nightly |
| 36 | + |
| 37 | +### Linux |
| 38 | +- Google Chrome |
| 39 | +- Chromium |
| 40 | +- Mozilla Firefox |
| 41 | + |
| 42 | +## Configuration Options |
| 43 | + |
| 44 | +You can customize the browser detection behavior in your `mycoder.config.js` file: |
| 45 | + |
| 46 | +```javascript |
| 47 | +// mycoder.config.js |
| 48 | +export default { |
| 49 | + // Other settings... |
| 50 | + |
| 51 | + // System browser detection settings |
| 52 | + browser: { |
| 53 | + // Whether to use system browsers or Playwright's bundled browsers |
| 54 | + useSystemBrowsers: true, |
| 55 | + |
| 56 | + // Preferred browser type (chromium, firefox, webkit) |
| 57 | + preferredType: 'chromium', |
| 58 | + |
| 59 | + // Custom browser executable path (overrides automatic detection) |
| 60 | + // executablePath: null, // e.g., '/path/to/chrome' |
| 61 | + }, |
| 62 | +}; |
| 63 | +``` |
| 64 | + |
| 65 | +### Configuration Options Explained |
| 66 | + |
| 67 | +| Option | Description | Default | |
| 68 | +|--------|-------------|---------| |
| 69 | +| `useSystemBrowsers` | Whether to use system-installed browsers if available | `true` | |
| 70 | +| `preferredType` | Preferred browser engine type (`chromium`, `firefox`, `webkit`) | `chromium` | |
| 71 | +| `executablePath` | Custom browser executable path (overrides automatic detection) | `null` | |
| 72 | + |
| 73 | +## Browser Selection Priority |
| 74 | + |
| 75 | +When selecting a browser, MyCoder follows this priority order: |
| 76 | + |
| 77 | +1. Custom executable path specified in `browser.executablePath` (if provided) |
| 78 | +2. System browser matching the preferred type specified in `browser.preferredType` |
| 79 | +3. Any available system browser |
| 80 | +4. Playwright's bundled browsers (fallback) |
| 81 | + |
| 82 | +## Troubleshooting |
| 83 | + |
| 84 | +If you encounter issues with browser detection: |
| 85 | + |
| 86 | +1. **Browser Not Found**: Ensure you have at least one supported browser installed on your system. |
| 87 | + |
| 88 | +2. **Browser Compatibility Issues**: Some websites may work better with specific browser types. Try changing the `preferredType` setting if you encounter compatibility issues. |
| 89 | + |
| 90 | +3. **Manual Override**: If automatic detection fails, you can manually specify the path to your browser using the `executablePath` option. |
| 91 | + |
| 92 | +4. **Fallback to Bundled Browsers**: If you prefer to use Playwright's bundled browsers, set `useSystemBrowsers` to `false`. |
| 93 | + |
| 94 | +## Examples |
| 95 | + |
| 96 | +### Using Chrome as the Preferred Browser |
| 97 | + |
| 98 | +```javascript |
| 99 | +// mycoder.config.js |
| 100 | +export default { |
| 101 | + browser: { |
| 102 | + useSystemBrowsers: true, |
| 103 | + preferredType: 'chromium', |
| 104 | + }, |
| 105 | +}; |
| 106 | +``` |
| 107 | + |
| 108 | +### Using Firefox as the Preferred Browser |
| 109 | + |
| 110 | +```javascript |
| 111 | +// mycoder.config.js |
| 112 | +export default { |
| 113 | + browser: { |
| 114 | + useSystemBrowsers: true, |
| 115 | + preferredType: 'firefox', |
| 116 | + }, |
| 117 | +}; |
| 118 | +``` |
| 119 | + |
| 120 | +### Specifying a Custom Browser Path |
| 121 | + |
| 122 | +```javascript |
| 123 | +// mycoder.config.js |
| 124 | +export default { |
| 125 | + browser: { |
| 126 | + useSystemBrowsers: true, |
| 127 | + executablePath: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe', // Windows example |
| 128 | + // executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', // macOS example |
| 129 | + // executablePath: '/usr/bin/google-chrome', // Linux example |
| 130 | + }, |
| 131 | +}; |
| 132 | +``` |
0 commit comments