Skip to content

[BUG] Locator.drag_to throws TypeError: drag_and_drop() got an unexpected keyword argument 'sourcePosition' and 'targetPosition' #1178

@tmarenko

Description

@tmarenko

Context:

  • Playwright Version: 1.19.1
  • Operating System: Linux Mint 20.2
  • Python version: 3.8.5
  • Browser: Chromium

Code Snippet

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(headless=False)
    try:
        page = browser.new_page()
        page.goto('https://en.wikipedia.org')
        random_locator1 = page.locator('//span[normalize-space()="Main page"]')
        random_locator2 = page.locator('//span[normalize-space()="Contents"]')
        random_locator1.drag_to(random_locator2, source_position={"x": 0, "y": 0})
        random_locator1.drag_to(random_locator2, target_position={"x": 0, "y": 0})
    finally:
        browser.close()

Describe the bug

Locator.drag_to throws TypeError: drag_and_drop() got an unexpected keyword argument 'sourcePosition' error when using source_position or target_position arguments.

Locator.drag_to sends these parameters in camelCase:

sourcePosition: Position = None,
targetPosition: Position = None,
) -> None:
params = locals_to_params(locals())
del params["target"]
return await self._frame.drag_and_drop(
self._selector, target._selector, strict=True, **params
)

to a function that has these parameters in snake_case:
async def drag_and_drop(
self,
source: str,
target: str,
source_position: Position = None,
target_position: Position = None,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions