Class PlaywrightService
java.lang.Object
com.shaft.mcp.PlaywrightService
MCP-safe Playwright tools backed by
SHAFT.GUI.Playwright.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappendText(locatorStrategy locatorStrategy, String locatorValue, String textValue) Appends text to a Playwright element.clear(locatorStrategy locatorStrategy, String locatorValue) Clears a Playwright element.click(locatorStrategy locatorStrategy, String locatorValue) Clicks a Playwright element.clickUsingJavaScript(locatorStrategy locatorStrategy, String locatorValue) Clicks a Playwright element using JavaScript.doubleClick(locatorStrategy locatorStrategy, String locatorValue) Double-clicks a Playwright element.dragAndDrop(locatorStrategy sourceLocatorStrategy, String sourceLocatorValue, locatorStrategy targetLocatorStrategy, String targetLocatorValue) Drags one Playwright element to another.Gets current Playwright page URL.getPageDom(int maxCharacters) Captures the current Playwright page DOM.getTitle()Gets current Playwright page title.hover(locatorStrategy locatorStrategy, String locatorValue) Hovers over a Playwright element.voidinitialize(String browser, boolean headless) Initializes a SHAFT Playwright browser session.booleanisDisplayed(locatorStrategy locatorStrategy, String locatorValue) Checks Playwright element visibility.booleanisEnabled(locatorStrategy locatorStrategy, String locatorValue) Checks Playwright element enabled state.Navigates the Playwright page to a URL.Navigates back in the Playwright page history.Navigates forward in the Playwright page history.Opens a new Playwright tab or window.voidquit()Quits the active SHAFT Playwright session.recordingCodeBlocks(String recordingPath, String driverVariableName) Generates copy-paste replay code from a Playwright recording.recordStart(String outputPath, String mode, boolean includeSensitiveValues) Starts recording Playwright actions performed through MCP Playwright tools.Returns Playwright recording status.recordStop(boolean discard) Stops Playwright recording.refresh()Refreshes the Playwright page.replayRecording(String recordingPath, String driverVariableName) Replays a Playwright recording against the active Playwright session.setValueUsingJavaScript(locatorStrategy locatorStrategy, String locatorValue, String textValue) Sets an element value using JavaScript.setWindowSize(int width, int height) Sets the Playwright viewport size.takeScreenshot(String outputPath, boolean includeBase64) Takes a PNG screenshot of the current Playwright page.type(locatorStrategy locatorStrategy, String locatorValue, String textValue) Types into a Playwright element.uploadFile(locatorStrategy locatorStrategy, String locatorValue, String filePath) Uploads a file through a Playwright file input.
-
Constructor Details
-
PlaywrightService
public PlaywrightService()Creates the default Playwright MCP service.
-
-
Method Details
-
initialize
@Tool(name="playwright_initialize", description="launches a SHAFT Playwright browser") public void initialize(String browser, boolean headless) Initializes a SHAFT Playwright browser session.- Parameters:
browser- chromium, chrome, firefox, webkit, or safari; blank uses SHAFT defaultsheadless- whether to launch headlessly
-
quit
@Tool(name="playwright_quit", description="closes the active SHAFT Playwright browser") public void quit()Quits the active SHAFT Playwright session. -
recordStart
@Tool(name="playwright_record_start", description="starts recording MCP Playwright actions to a workspace JSON file") public McpMobileRecordingStatus recordStart(String outputPath, String mode, boolean includeSensitiveValues) Starts recording Playwright actions performed through MCP Playwright tools.- Parameters:
outputPath- workspace-contained recording JSON output pathmode- recording labelincludeSensitiveValues- whether typed values may be persisted- Returns:
- recorder status
-
recordStatus
@Tool(name="playwright_record_status", description="returns the active MCP Playwright recording status") public McpMobileRecordingStatus recordStatus()Returns Playwright recording status.- Returns:
- recorder status
-
recordStop
@Tool(name="playwright_record_stop", description="stops MCP Playwright recording and optionally discards the JSON file") public McpMobileRecordingStatus recordStop(boolean discard) Stops Playwright recording.- Parameters:
discard- whether to delete the recording output- Returns:
- final recorder status
-
recordingCodeBlocks
@Tool(name="playwright_recording_code_blocks", description="generates reusable copy-paste SHAFT Playwright replay code blocks") public McpMobileReplayResult recordingCodeBlocks(String recordingPath, String driverVariableName) Generates copy-paste replay code from a Playwright recording.- Parameters:
recordingPath- workspace-contained recording pathdriverVariableName- driver variable name to use in generated snippets- Returns:
- replay code blocks
-
replayRecording
@Tool(name="playwright_replay_recording", description="replays an MCP Playwright recording against the active SHAFT Playwright driver") public McpMobileReplayResult replayRecording(String recordingPath, String driverVariableName) Replays a Playwright recording against the active Playwright session.- Parameters:
recordingPath- workspace-contained recording pathdriverVariableName- driver variable name to use in generated snippets- Returns:
- replay result
-
refresh
@Tool(name="playwright_browser_refresh", description="refreshes the SHAFT Playwright page") public McpMobileActionResult refresh()Refreshes the Playwright page.- Returns:
- recorded action metadata
-
setWindowSize
@Tool(name="playwright_browser_set_window_size", description="sets the SHAFT Playwright viewport size") public McpMobileActionResult setWindowSize(int width, int height) Sets the Playwright viewport size.- Parameters:
width- viewport widthheight- viewport height- Returns:
- recorded action metadata
-
newWindow
@Tool(name="playwright_browser_new_window", description="opens a new SHAFT Playwright tab or window") public McpMobileActionResult newWindow(String targetUrl, String windowType) Opens a new Playwright tab or window.- Parameters:
targetUrl- optional URL; blank opens about:blankwindowType- TAB or WINDOW- Returns:
- recorded action metadata
-
getCurrentUrl
@Tool(name="playwright_browser_get_current_url", description="gets current SHAFT Playwright page URL") public String getCurrentUrl()Gets current Playwright page URL.- Returns:
- current URL
-
getTitle
@Tool(name="playwright_browser_get_title", description="gets current SHAFT Playwright page title") public String getTitle()Gets current Playwright page title.- Returns:
- page title
-
getPageDom
@Tool(name="playwright_browser_get_page_dom", description="gets the current SHAFT Playwright page DOM for browser automation inspection") public McpPageDomSnapshot getPageDom(int maxCharacters) Captures the current Playwright page DOM.- Parameters:
maxCharacters- maximum DOM characters to return- Returns:
- page DOM snapshot
-
takeScreenshot
@Tool(name="playwright_browser_take_screenshot", description="takes a PNG screenshot of the current SHAFT Playwright page") public McpScreenshotResult takeScreenshot(String outputPath, boolean includeBase64) Takes a PNG screenshot of the current Playwright page.- Parameters:
outputPath- optional workspace-contained output file pathincludeBase64- whether to include base64 bytes in the response- Returns:
- screenshot metadata
-
click
@Tool(name="playwright_element_click", description="clicks an element using SHAFT Playwright") public McpMobileActionResult click(locatorStrategy locatorStrategy, String locatorValue) Clicks a Playwright element. -
clickUsingJavaScript
@Tool(name="playwright_element_click_js", description="clicks an element using JavaScript in SHAFT Playwright") public McpMobileActionResult clickUsingJavaScript(locatorStrategy locatorStrategy, String locatorValue) Clicks a Playwright element using JavaScript. -
doubleClick
@Tool(name="playwright_element_double_click", description="double-clicks an element using SHAFT Playwright") public McpMobileActionResult doubleClick(locatorStrategy locatorStrategy, String locatorValue) Double-clicks a Playwright element. -
hover
@Tool(name="playwright_element_hover", description="hovers over an element using SHAFT Playwright") public McpMobileActionResult hover(locatorStrategy locatorStrategy, String locatorValue) Hovers over a Playwright element. -
type
@Tool(name="playwright_element_type", description="types value into an element using SHAFT Playwright") public McpMobileActionResult type(locatorStrategy locatorStrategy, String locatorValue, String textValue) Types into a Playwright element. -
appendText
@Tool(name="playwright_element_append_text", description="appends text to an element using SHAFT Playwright") public McpMobileActionResult appendText(locatorStrategy locatorStrategy, String locatorValue, String textValue) Appends text to a Playwright element. -
setValueUsingJavaScript
@Tool(name="playwright_element_set_value_js", description="sets an element value using JavaScript in SHAFT Playwright") public McpMobileActionResult setValueUsingJavaScript(locatorStrategy locatorStrategy, String locatorValue, String textValue) Sets an element value using JavaScript. -
clear
@Tool(name="playwright_element_clear", description="clears an element using SHAFT Playwright") public McpMobileActionResult clear(locatorStrategy locatorStrategy, String locatorValue) Clears a Playwright element. -
uploadFile
@Tool(name="playwright_element_upload_file", description="uploads a file through an element using SHAFT Playwright") public McpMobileActionResult uploadFile(locatorStrategy locatorStrategy, String locatorValue, String filePath) Uploads a file through a Playwright file input. -
dragAndDrop
@Tool(name="playwright_element_drag_and_drop", description="drags and drops an element using SHAFT Playwright") public McpMobileActionResult dragAndDrop(locatorStrategy sourceLocatorStrategy, String sourceLocatorValue, locatorStrategy targetLocatorStrategy, String targetLocatorValue) Drags one Playwright element to another. -
isDisplayed
@Tool(name="playwright_element_is_displayed", description="checks whether a SHAFT Playwright element is visible") public boolean isDisplayed(locatorStrategy locatorStrategy, String locatorValue) Checks Playwright element visibility. -
isEnabled
@Tool(name="playwright_element_is_enabled", description="checks whether a SHAFT Playwright element is enabled") public boolean isEnabled(locatorStrategy locatorStrategy, String locatorValue) Checks Playwright element enabled state.
-