Class EngineService

java.lang.Object
com.shaft.mcp.EngineService

@Service public class EngineService extends Object
  • Constructor Details

    • EngineService

      public EngineService()
      Creates the default engine service, wiring a default PlaywrightService for direct Java callers and tests that construct this class without Spring.
  • Method Details

    • initializeDriver

      @Tool(name="driver_initialize", description="launches browser, Playwright, or a mobile session; optional engine selects web (default) | playwright | mobile_native | mobile_web; for mobile engines, optional nested mobileOptions carries native/web-emulation parameters, absorbing mobile_initialize_native/mobile_initialize_web_emulation") public void initializeDriver(@ToolParam(required=false,description="browser to launch on the WEB engine; blank/omitted defers to the configured targetBrowserName property (default chrome); PLAYWRIGHT/MOBILE engines resolve their own default independently") BrowserType targetBrowser, @ToolParam(required=false) ActiveEngine engine, @ToolParam(required=false) McpMobileInitOptions mobileOptions)
      Initializes the WebDriver for the specified browser type, or another engine session when engine selects one.
      Parameters:
      targetBrowser - The type of browser to initialize (e.g., CHROME, FIREFOX).
      engine - which engine to start; blank/omitted defaults to ActiveEngine.WEB. ActiveEngine.PLAYWRIGHT starts a SHAFT Playwright session instead of a WebDriver session. ActiveEngine.MOBILE_NATIVE/ActiveEngine.MOBILE_WEB start an Appium native or Chrome/Edge mobile-emulation session using mobileOptions (design doc amendment A9).
      mobileOptions - optional nested request carrying the union of the former mobile_initialize_native/mobile_initialize_web_emulation parameters; only read when engine is a mobile engine; unset fields resolve from SHAFT.Properties exactly as those tools did
    • initializeDriver

      public void initializeDriver(BrowserType targetBrowser)
      Java-caller convenience overload defaulting engine to ActiveEngine.WEB; not an MCP tool.
      Parameters:
      targetBrowser - The type of browser to initialize (e.g., CHROME, FIREFOX).
    • quitDriver

      @Tool(name="driver_quit", description="closes whichever engine session (web, mobile, or Playwright) is currently active") public void quitDriver()
      Quits whichever engine session is currently active (web, mobile, or Playwright), closing all associated browser windows.
    • generateTestReport

      @Tool(name="generate_test_report", description="generates a test report for the current session") public void generateTestReport()
      Generate a test report for the current session. This method compiles and generates a detailed test report based on the actions performed during the session. It utilizes SHAFT's reporting capabilities to create a comprehensive report that includes information such as test steps, outcomes, screenshots, and logs. The generated report is saved in a predefined location for easy access and review. This method should be called at the end of the test session to ensure all actions are documented.
    • getPageSource

      public String getPageSource()
      Get the source code of the current page. This is a support method for the AI agent to better explore the page.
      Returns:
      The HTML source code of the current page as a string.