Skip to content

Commit ef369fd

Browse files
Merge pull request #86 from executeautomation/Add-ancillary-features-missing-from-our-MCP-Server
Add ancillary features missing from our mcp server
2 parents 523c5c5 + 28fafec commit ef369fd

17 files changed

+1057
-69
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![smithery badge](https://smithery.ai/badge/@executeautomation/playwright-mcp-server)](https://smithery.ai/server/@executeautomation/playwright-mcp-server)
44

5-
A Model Context Protocol server that provides browser automation capabilities using Playwright. This server enables LLMs to interact with web pages, take screenshots, and execute JavaScript in a real browser environment.
5+
A Model Context Protocol server that provides browser automation capabilities using Playwright. This server enables LLMs to interact with web pages, take screenshots, generate test code, web scraps the page and execute JavaScript in a real browser environment.
66

77
<a href="https://glama.ai/mcp/servers/yh4lgtwgbe"><img width="380" height="200" src="https://glama.ai/mcp/servers/yh4lgtwgbe/badge" alt="mcp-playwright MCP server" /></a>
88

docs/docs/playwright-web/Examples.md

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,93 @@ by opening real browser like this
3434

3535
And once the entire test operation completes, we will be presented with the entire details of how the automation did happened.
3636

37-
![Playwright MCP Server](./img/mcp-result.png)
37+
![Playwright MCP Server](./img/mcp-result.png)
38+
39+
### Using Browser History Navigation
40+
41+
You can navigate through the browser's history using the new navigation controls:
42+
43+
```bdd
44+
Given I navigate to website "https://example.com"
45+
When I navigate to website "https://example.com/about"
46+
And I navigate back in browser history
47+
Then the current page should be "https://example.com"
48+
When I navigate forward in browser history
49+
Then the current page should be "https://example.com/about"
50+
```
51+
52+
### Using Drag and Drop Functionality
53+
54+
You can drag and drop elements using the new drag tool:
55+
56+
```bdd
57+
Given I navigate to website "https://example.com/drag-drop-demo"
58+
When I drag element with id "draggable" to element with id "droppable"
59+
Then I should see confirmation message "Dropped!"
60+
```
61+
62+
### Using Keyboard Interactions
63+
64+
You can simulate keyboard presses with the new keyboard tool:
65+
66+
```bdd
67+
Given I navigate to website "https://example.com/form"
68+
When I focus on the input field with id "search-box"
69+
And I press the "Enter" key
70+
Then the search results should appear
71+
```
72+
73+
### Saving Page as PDF
74+
75+
You can save the current page as a PDF file:
76+
77+
```bdd
78+
Given I navigate to website "https://example.com/report"
79+
When I save the current page as a PDF in "/downloads" folder with name "report.pdf"
80+
Then I should see confirmation that the PDF was saved
81+
```
82+
83+
Advanced example with custom options:
84+
85+
```bdd
86+
Given I navigate to website "https://example.com/invoice"
87+
When I save the page as PDF with the following settings:
88+
| Setting | Value |
89+
| ----------------- | --------- |
90+
| Output Path | /downloads |
91+
| Filename | invoice.pdf |
92+
| Format | Letter |
93+
| Print Background | true |
94+
| Top Margin | 2cm |
95+
| Right Margin | 1cm |
96+
| Bottom Margin | 2cm |
97+
| Left Margin | 1cm |
98+
Then I should see confirmation that the PDF was saved
99+
```
100+
101+
### Extracting Page Content
102+
103+
You can extract visible text content from the page:
104+
105+
```bdd
106+
Given I navigate to website "https://example.com/article"
107+
When I extract all visible text from the page
108+
Then I should see the article content in plain text without hidden elements
109+
```
110+
111+
You can also get the complete HTML of the page:
112+
113+
```bdd
114+
Given I navigate to website "https://example.com/products"
115+
When I extract the HTML content of the page
116+
Then I should receive the complete HTML structure of the page
117+
```
118+
119+
Example use case for content analysis:
120+
121+
```bdd
122+
Given I navigate to website "https://example.com/pricing"
123+
When I extract all visible text from the page
124+
Then I should be able to analyze the text to find pricing information
125+
And I can determine if the "Enterprise" plan mentions "custom pricing"
126+
```

docs/docs/playwright-web/Supported-Tools.mdx

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import YouTubeVideoEmbed from '@site/src/components/HomepageFeatures/YouTubeVide
99

1010
Playwright MCP for Browser automation has following key features
1111
- Console log monitoring
12+
- Code Generation
13+
- Web Scraping
1214
- Screenshot capabilities
1315
- JavaScript execution
1416
- Basic web interaction (navigation, clicking, form filling, drop down select and hover)
@@ -23,6 +25,65 @@ Playwright MCP for Browser automation has following key features
2325
Playwright UI automation is supported for very limited feature sets, more features will be added in upcoming days. Please feel free to fork the repo and add the feature and raise PR, will can build the library together!
2426
:::
2527

28+
## Code Generation Tools
29+
30+
These tools allow you to record and generate reusable Playwright test scripts.
31+
32+
### start_codegen_session
33+
Start a new code generation session to record Playwright actions.
34+
35+
- **Inputs:**
36+
- **`options`** *(object, required)*:
37+
Code generation options:
38+
- **`outputPath`** *(string, required)*:
39+
Directory path where generated tests will be saved (use absolute path).
40+
- **`testNamePrefix`** *(string, optional)*:
41+
Prefix to use for generated test names (default: 'GeneratedTest').
42+
- **`includeComments`** *(boolean, optional)*:
43+
Whether to include descriptive comments in generated tests.
44+
45+
- **Response:**
46+
- Session ID for the newly created code generation session.
47+
48+
---
49+
50+
### end_codegen_session
51+
End a code generation session and generate the test file.
52+
53+
- **Inputs:**
54+
- **`sessionId`** *(string, required)*:
55+
ID of the session to end.
56+
57+
- **Response:**
58+
- Information about the generated test file.
59+
60+
---
61+
62+
### get_codegen_session
63+
Get information about a code generation session.
64+
65+
- **Inputs:**
66+
- **`sessionId`** *(string, required)*:
67+
ID of the session to retrieve.
68+
69+
- **Response:**
70+
- Session information including recorded actions and status.
71+
72+
---
73+
74+
### clear_codegen_session
75+
Clear a code generation session without generating a test.
76+
77+
- **Inputs:**
78+
- **`sessionId`** *(string, required)*:
79+
ID of the session to clear.
80+
81+
- **Response:**
82+
- Confirmation that the session was cleared.
83+
84+
---
85+
86+
## Browser Automation Tools
2687

2788
### Playwright_navigate
2889

@@ -214,3 +275,71 @@ Get the HTML content of the current page.
214275
- **Response:**
215276
- **`content`** *(string)*:
216277
The complete HTML content of the current page.
278+
279+
---
280+
281+
### playwright_go_back
282+
Navigate back in browser history.
283+
284+
- **Response:**
285+
- Confirmation message that the browser has navigated back in its history.
286+
287+
---
288+
289+
### playwright_go_forward
290+
Navigate forward in browser history.
291+
292+
- **Response:**
293+
- Confirmation message that the browser has navigated forward in its history.
294+
295+
---
296+
297+
### playwright_drag
298+
Drag an element to a target location.
299+
300+
- **Inputs:**
301+
- **`sourceSelector`** *(string)*:
302+
CSS selector for the element to drag.
303+
- **`targetSelector`** *(string)*:
304+
CSS selector for the target location.
305+
306+
- **Response:**
307+
- Confirmation message that the drag operation has been performed.
308+
309+
---
310+
311+
### playwright_press_key
312+
Press a keyboard key.
313+
314+
- **Inputs:**
315+
- **`key`** *(string)*:
316+
Key to press (e.g. 'Enter', 'ArrowDown', 'a').
317+
- **`selector`** *(string, optional)*:
318+
CSS selector for an element to focus before pressing the key.
319+
320+
- **Response:**
321+
- Confirmation message indicating which key was pressed.
322+
323+
---
324+
325+
### playwright_save_as_pdf
326+
Save the current page as a PDF file.
327+
328+
- **Inputs:**
329+
- **`outputPath`** *(string)*:
330+
Directory path where the PDF will be saved.
331+
- **`filename`** *(string, optional, default: "page.pdf")*:
332+
Name of the PDF file.
333+
- **`format`** *(string, optional, default: "A4")*:
334+
Page format (e.g. 'A4', 'Letter').
335+
- **`printBackground`** *(boolean, optional, default: true)*:
336+
Whether to print background graphics.
337+
- **`margin`** *(object, optional)*:
338+
Page margins with the following properties:
339+
- **`top`** *(string)*: Top margin (e.g. '1cm').
340+
- **`right`** *(string)*: Right margin (e.g. '1cm').
341+
- **`bottom`** *(string)*: Bottom margin (e.g. '1cm').
342+
- **`left`** *(string)*: Left margin (e.g. '1cm').
343+
344+
- **Response:**
345+
- Path to the saved PDF file.

docs/docs/release.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,28 @@ import YouTubeVideoEmbed from '@site/src/components/HomepageFeatures/YouTubeVide
55

66
# Release Notes
77

8+
## Version 1.0.3
9+
- **Code Generation Capabilities**: Added new code generation capability 🎭
10+
- `start_codegen_session`: Start a new session to record Playwright actions
11+
- `end_codegen_session`: End a session and generate test file
12+
- `get_codegen_session`: Retrieve information about a session
13+
- `clear_codegen_session`: Clear a session without generating a test
14+
- Ability to record real browser interactions and convert them to reusable Playwright tests
15+
- Support for customizing test output path, test names, and including descriptive comments
16+
- **Enhanced Browser Navigation**: Added new navigation control tools 🧭
17+
- `playwright_go_back`: Navigate back in browser history
18+
- `playwright_go_forward`: Navigate forward in browser history
19+
- **Advanced Interaction**: Added new interaction tools for more complex scenarios 🔄
20+
- `playwright_drag`: Drag elements from one location to another
21+
- `playwright_press_key`: Press keyboard keys with optional element focus
22+
- **Output Capabilities**: Added content export functionality 📄
23+
- `playwright_save_as_pdf`: Save the current page as a PDF file with customizable options
24+
- **Content Extraction**: Added tools for retrieving page content 📝
25+
- `playwright_get_visible_text`: Extract all visible text content from the current page
26+
- `playwright_get_visible_html`: Get the complete HTML content of the current page
27+
- Comprehensive test coverage for all new tools
28+
- Updated documentation with examples and usage detail
29+
830
## Version 1.0.2
931
- **Multi-Browser Support**: Added support for Firefox and WebKit browsers in addition to Chromium 🌐
1032
- New `browserType` parameter for `playwright_navigate` tool allows specifying browser engine

0 commit comments

Comments
 (0)