Skip to content

feat: add Playwright web browser automation support#208

Open
ihubanov wants to merge 1 commit intoappium:mainfrom
ihubanov:feat/playwright-web-automation
Open

feat: add Playwright web browser automation support#208
ihubanov wants to merge 1 commit intoappium:mainfrom
ihubanov:feat/playwright-web-automation

Conversation

@ihubanov
Copy link
Copy Markdown

Summary

  • Adds Playwright as a new platform alongside Android and iOS, enabling web browser automation (chromium, firefox, webkit) through the same MCP tool interface
  • Introduces a PlaywrightDriver adapter that bridges Playwright's API to the existing UUID-based element model, so all existing interaction tools (click, find, setText, getText, screenshot, etc.) work seamlessly with web sessions
  • Adds 14 new Playwright-specific tools for web-only operations: navigation, JS evaluation, tab management, hover, select option, keyboard input

Details

Core Infrastructure

  • src/playwright-adapter.tsPlaywrightDriver class wrapping Browser/BrowserContext/Page with an element UUID registry
  • src/session-store.ts — Added PlaywrightDriver to DriverInstance union, isPlaywrightDriverSession() type guard, 'Web' platform constant
  • src/command.ts — Added Playwright branches to all 15 command abstraction functions

Session Management

  • select_platform — Added 'web' platform option
  • create_session — Added 'web' platform with browser (chromium/firefox/webkit), headless, url, and viewport parameters. Uses realistic 1920x1080 viewport and real browser user-agent by default

New Playwright Tools (src/tools/web/)

Tool Description
playwright_navigate Navigate to a URL
playwright_go_back / go_forward / reload Browser history navigation
playwright_get_url Get current URL and title
playwright_evaluate Execute JavaScript in page context
playwright_type Type text character-by-character
playwright_press_key Press keyboard key/combo
playwright_hover Hover over element
playwright_select_option Select from <select> dropdown
playwright_new_tab / switch_tab / list_tabs / close_tab Tab management

Existing Tools Extended for Web

  • appium_find_element — Added new strategies: text, data-testid, tag name, placeholder, role
  • appium_click, appium_set_value, appium_get_text, appium_screenshot, appium_element_screenshot, appium_get_page_source, appium_get_active_element, generate_locators — All work with Playwright sessions

Mobile-Only Tools (unchanged)

App management, device managers, iOS tools, geolocation, context switching, scroll/swipe/pinch gestures, orientation, lock/unlock — these correctly throw descriptive errors if called on a Playwright session.

Test plan

  • All 84 existing tests pass — no regressions
  • TypeScript builds cleanly with no errors
  • Smoke tested: PlaywrightDriver creation, findElement (by id, placeholder, css, text), fill, click, textContent, screenshot, page.content(), deleteSession
  • End-to-end tested: created web session, navigated to a live website, interacted with UI elements, extracted page data, managed tabs
  • Reviewers may want to verify with npm test and npm run build
  • Test with firefox and webkit browsers

Add Playwright as a new platform alongside Android and iOS, enabling
web browser automation through the same MCP tool interface.

Core changes:
- PlaywrightDriver adapter bridging Playwright's API to the existing
  UUID-based element model used by all tools
- Extended session-store with Playwright type guard and 'Web' platform
- Extended command.ts with Playwright branches for all operations
- Added 'web' platform to select_platform and create_session tools
- Support for chromium, firefox, and webkit browsers
- Realistic user-agent and 1920x1080 default viewport

New Playwright-specific tools (14):
- playwright_navigate, playwright_go_back, playwright_go_forward,
  playwright_reload, playwright_get_url
- playwright_evaluate (execute JS in page context)
- playwright_type, playwright_press_key
- playwright_hover, playwright_select_option
- playwright_new_tab, playwright_switch_tab, playwright_list_tabs,
  playwright_close_tab

Existing tools that now work with both mobile and web:
- appium_find_element (with new strategies: text, data-testid,
  tag name, placeholder, role)
- appium_click, appium_set_value, appium_get_text
- appium_screenshot, appium_element_screenshot
- appium_get_page_source, appium_get_active_element
- generate_locators
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Mar 15, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: ihubanov / name: snf (ea94cee)

@KazuCocoa
Copy link
Copy Markdown
Member

I'm not sure we want to add this non-Appium thing to this repository for now to focus on Appium stuff, even though I understand it would help some automation scenarios. Perhaps this could be in a fork repository or project right now.

What do you think of this @saikrishna321 @SrinivasanTarget

@saikrishna321
Copy link
Copy Markdown
Member

I Agree with @KazuCocoa we will focus to keep appium related things in this mcp. Also playwright already has a mcp. So if users are interested they can side load that mcp with appium mcp.

@ihubanov
Copy link
Copy Markdown
Author

Sure, it's up to you guys! I was thinking if someone wants to build webapp, it will be useful, however you know the roadmap better and you decide how to move on! 🙏
By the way I've played with playwright MCPs... Believe me, they are crap compared to this one 🙈

Cheers!

@KazuCocoa KazuCocoa added the enhancement New feature or request label Mar 16, 2026
@SrinivasanTarget
Copy link
Copy Markdown
Member

@ihubanov Thanks for your efforts, and we value your time a lot. As discussed above, we didn't want to mix things up here, as the primary goal is to have mcp only for appium.

Looking forward to seeing you back with more contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants