browser_drag
Drag and drop elements in Chrome using precise selectors, bypassing anti-bot detection for automation and testing on protected websites.
Instructions
Drag an element to another element
Args:
sourceSelector: The selector for the element to drag - required
targetSelector: The selector for the target location - required
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sourceSelector | Yes | ||
| targetSelector | Yes |
Implementation Reference
- The handler function for the 'browser_drag' tool. It is registered via @mcp.tool() decorator. Performs drag-and-drop operation from source element to target element using Selenium's ActionChains.@mcp.tool() async def browser_drag( sourceSelector: str, targetSelector: str, ): """Drag an element to another element Args: sourceSelector: The selector for the element to drag - required targetSelector: The selector for the target location - required """ assert sourceSelector, "Source selector is required" assert targetSelector, "Target selector is required" async def drag_handler(driver: uc.Chrome): source = driver.find_element(By.CSS_SELECTOR, sourceSelector) target = driver.find_element(By.CSS_SELECTOR, targetSelector) ActionChains(driver).drag_and_drop(source, target).perform() return await create_success_response( f"Dragged {sourceSelector} to {targetSelector}" ) return await tool.safe_execute( ToolContext(webdriver=await ensure_browser()), drag_handler )