refresh
Refresh the current browser page to load updated content and re-render elements.
Instructions
Refresh the current page.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/selenium_mcp_server/server.py:77-108 (handler)The MCP tool handler for 'refresh' — decorated with @mcp.tool() and delegates to browser.refresh via the _run helper.
@mcp.tool() def refresh() -> dict[str, Any]: """Refresh the current page.""" return _run("refresh", browser.refresh) @mcp.tool() def set_window_size(width: int, height: int) -> dict[str, Any]: """Set the browser window size.""" return _run("set_window_size", browser.set_window_size, width, height) @mcp.tool() def open_new_tab(url: str | None = None) -> dict[str, Any]: """Open a new browser tab and optionally navigate it to a URL.""" return _run("open_new_tab", browser.open_new_tab, url) @mcp.tool() def switch_window(handle: str) -> dict[str, Any]: """Switch to a browser window or tab by Selenium window handle.""" return _run("switch_window", browser.switch_window, handle) @mcp.tool() def close_window() -> dict[str, Any]: """Close the active browser window or tab.""" return _run("close_window", browser.close_window) @mcp.tool() def find_element( - src/selenium_mcp_server/server.py:77-80 (registration)The @mcp.tool() decorator on the refresh() function registers it as an MCP tool with the FastMCP server instance.
@mcp.tool() def refresh() -> dict[str, Any]: """Refresh the current page.""" return _run("refresh", browser.refresh) - The BrowserManager.refresh() method which acquires the lock, calls Selenium's WebDriver.refresh(), and returns the current BrowserState.
def refresh(self) -> BrowserState: with self._lock: self._require_driver().refresh() return self.state() - The _run helper function used by the refresh handler to execute the browser method, convert its result to a dict via _as_dict, and handle exceptions.
def _run(action: str, func: Any, *args: Any, **kwargs: Any) -> Any: try: return _as_dict(func(*args, **kwargs)) except BrowserError: logger.exception("Browser action failed: %s", action) raise except Exception as exc: logger.exception("Unexpected Selenium MCP error during %s", action) raise BrowserError(f"{action} failed: {exc}") from exc