browser-automation.mdx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ---
  2. title: "Browser Automation"
  3. sidebarTitle: "Browser Automation"
  4. description: "Interact with websites through Cline's controlled browser instance."
  5. ---
  6. Browser automation allows Cline to interact with web content directly through a controlled Chrome instance. It can view websites, test applications, fill forms, and capture screenshots.
  7. ## Capabilities
  8. - Visit websites and view content
  9. - Test locally running web applications
  10. - Fill out forms and click elements
  11. - Capture screenshots
  12. - Monitor console logs and errors
  13. - Scroll through pages
  14. ## Basic Commands
  15. Ask Cline to use the browser with simple instructions:
  16. ```text
  17. Use the browser to check https://example.com
  18. ```
  19. ```text
  20. Click the login button
  21. ```
  22. ```text
  23. Type 'Hello world' in the search box
  24. ```
  25. ```text
  26. Scroll down to see more content
  27. ```
  28. ```text
  29. Close the browser
  30. ```
  31. ## Example Workflows
  32. ### Testing a Web Application
  33. ```text
  34. Start my React app with "npm start" and check if it's working at http://localhost:3000
  35. ```
  36. ### Analyzing a Website
  37. ```text
  38. Visit https://example.com and tell me about its design and layout
  39. ```
  40. ### Form Testing
  41. ```text
  42. Go to https://example.com/contact, fill out the form with test data, and submit
  43. ```
  44. ## Important Details
  45. ### One Browser at a Time
  46. Cline can only run one browser at a time. To visit a different site:
  47. - Navigate to a new URL in the same session
  48. - Or close the browser and open a new one
  49. ### Close Before Other Tools
  50. Close the browser before editing files or running commands:
  51. ```text
  52. Close the browser and update the CSS to fix the alignment issue we saw
  53. ```
  54. ### Fixed Viewport
  55. The browser has a fixed 900x600 pixel viewport. Cline shares screenshots after each action so you see exactly what it sees.
  56. ### Console Logs
  57. Cline captures browser console logs, which is helpful for debugging. These are included with each screenshot.
  58. ## Common Use Cases
  59. - **Web Development**: Test websites and applications
  60. - **UI/UX Review**: Get feedback on design and usability
  61. - **Content Research**: Browse to gather information
  62. - **Form Testing**: Verify forms work correctly
  63. - **Responsive Testing**: Check appearance at different sizes
  64. ## Troubleshooting
  65. | Issue | Solution |
  66. |-------|----------|
  67. | Website doesn't load | Use full URL with http:// or https:// |
  68. | Click doesn't work | Describe element location more precisely |
  69. | Browser seems stuck | Close browser and try again |
  70. ## WSL Configuration
  71. When running VS Code in WSL, configure Windows to allow WSL to connect to Chrome:
  72. ### Allow Connection (PowerShell as Admin)
  73. ```powershell
  74. New-NetFirewallRule -DisplayName "WSL Chrome Debug" -Direction Inbound -LocalPort 9222 -Protocol TCP -Action Allow
  75. ```
  76. ### Configure Cline
  77. 1. Open VS Code settings
  78. 2. Search for "Cline: Chrome Executable Path"
  79. 3. Set to your Chrome path (e.g., `C:\Program Files\Google\Chrome\Application\chrome.exe`)