feat: add Playwright web browser automation support#208
feat: add Playwright web browser automation support#208ihubanov wants to merge 1 commit intoappium:mainfrom
Conversation
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
|
|
|
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 |
|
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. |
|
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! 🙏 Cheers! |
|
@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. |
Summary
PlaywrightDriveradapter 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 sessionsDetails
Core Infrastructure
src/playwright-adapter.ts—PlaywrightDriverclass wrapping Browser/BrowserContext/Page with an element UUID registrysrc/session-store.ts— AddedPlaywrightDrivertoDriverInstanceunion,isPlaywrightDriverSession()type guard,'Web'platform constantsrc/command.ts— Added Playwright branches to all 15 command abstraction functionsSession Management
select_platform— Added'web'platform optioncreate_session— Added'web'platform withbrowser(chromium/firefox/webkit),headless,url, andviewportparameters. Uses realistic 1920x1080 viewport and real browser user-agent by defaultNew Playwright Tools (
src/tools/web/)playwright_navigateplaywright_go_back/go_forward/reloadplaywright_get_urlplaywright_evaluateplaywright_typeplaywright_press_keyplaywright_hoverplaywright_select_option<select>dropdownplaywright_new_tab/switch_tab/list_tabs/close_tabExisting Tools Extended for Web
appium_find_element— Added new strategies:text,data-testid,tag name,placeholder,roleappium_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 sessionsMobile-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
npm testandnpm run build