You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
as already shared in Discord, Iam not able to create a Drag and Drop movement. Maybe I do something wrong, but the documentation didnt really help me there, for up() and down() it just asks for (**kwargs).
I made a small example of the problem and of what I tried:
import asyncio
from selenium_driverless import webdriver
async def test_drag_and_drop():
# Create driver
driver = await webdriver.Chrome()
try:
# Navigate to test page
await driver.get("https://kaliiiiiiiiii.github.io/Selenium-Driverless/index.html")
await asyncio.sleep(1) # Wait for page load
# Find source and target elements
source_element = await driver.find_element(
"xpath",
"//div[@class='wy-menu wy-menu-vertical']//a[@href='api/WebELement.html']"
)
target_element = await driver.find_element(
"xpath",
"//*[@id='rtd-search-form']"
)
if not source_element or not target_element:
print("Could not find required elements")
return
print("Calculating element positions...")
source_pos = await source_element.mid_location()
target_pos = await target_element.mid_location()
print(f"Source position: {source_pos}")
print(f"Target position: {target_pos}")
pointer = driver.current_pointer
# Variant 1: No arguments for down/up
print("\nTesting Variant 1: down()/up() without arguments")
try:
await pointer.move_to(source_pos[0], source_pos[1])
await driver.sleep(0.2)
await pointer.down() # No arguments
await driver.sleep(0.2)
await pointer.move_to(target_pos[0], target_pos[1])
await driver.sleep(0.2)
await pointer.up() # No arguments
print("Variant 1 completed")
except Exception as e:
print(f"Variant 1 error: {e}")
await asyncio.sleep(1)
# Variant 2: Complete tuple from mid_location
print("\nTesting Variant 2: down()/up() with complete tuple")
try:
await pointer.move_to(source_pos[0], source_pos[1])
await driver.sleep(0.2)
await pointer.down(source_pos) # Complete tuple
await driver.sleep(0.2)
await pointer.move_to(target_pos[0], target_pos[1])
await driver.sleep(0.2)
await pointer.up(target_pos) # Complete tuple
print("Variant 2 completed")
except Exception as e:
print(f"Variant 2 error: {e}")
await asyncio.sleep(1)
# Variant 3: Separate x,y coordinates from mid_location
print("\nTesting Variant 3: down()/up() with separate x,y coordinates")
try:
await pointer.move_to(source_pos[0], source_pos[1])
await driver.sleep(0.2)
await pointer.down(source_pos[0], source_pos[1]) # Separate coordinates
await driver.sleep(0.2)
await pointer.move_to(target_pos[0], target_pos[1])
await driver.sleep(0.2)
await pointer.up(target_pos[0], target_pos[1]) # Separate coordinates
print("Variant 3 completed")
except Exception as e:
print(f"Variant 3 error: {e}")
await asyncio.sleep(2) # Wait to see the results
finally:
await driver.quit()
if __name__ == "__main__":
asyncio.run(test_drag_and_drop())
Testing Variant 1: down()/up() without arguments
Variant 1 error: PointerEvent.init() missing 2 required positional arguments: 'x' and 'y'
Testing Variant 2: down()/up() with complete tuple
Variant 2 error: Pointer.down() takes 1 positional argument but 2 were given
Testing Variant 3: down()/up() with separate x,y coordinates
Variant 3 error: Pointer.down() takes 1 positional argument but 3 were given
Process finished with exit code 0
I think it would be great to add a Pointer.drag_n_drop() with a start element (or coordinate) and end element (or coordinate). I hope you can fix the bug or tell me, when it was my fault ^^
The text was updated successfully, but these errors were encountered:
Hey,
as already shared in Discord, Iam not able to create a Drag and Drop movement. Maybe I do something wrong, but the documentation didnt really help me there, for up() and down() it just asks for (**kwargs).
I made a small example of the problem and of what I tried:
Result:
I think it would be great to add a Pointer.drag_n_drop() with a start element (or coordinate) and end element (or coordinate). I hope you can fix the bug or tell me, when it was my fault ^^
The text was updated successfully, but these errors were encountered: