Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebElement.move_to() not working #276

Open
Acanis87 opened this issue Nov 5, 2024 · 0 comments
Open

WebElement.move_to() not working #276

Acanis87 opened this issue Nov 5, 2024 · 0 comments
Labels
bug Something isn't working unconfirmed a bug which hasn't been reproduced yet

Comments

@Acanis87
Copy link

Acanis87 commented Nov 5, 2024

Hey,

I tried the new move_to() and it wasnt working. I thought its my code and tried a lot, but always the same error:
... failed: '>' not supported between instances of 'int' and 'NoneType'

I let Claude AI create a minimal code to proof:

import asyncio
from selenium_driverless import webdriver


async def test_move_to():
    # Create driver
    driver = await webdriver.Chrome()
    try:
        # Navigate to page
        await driver.get("https://kaliiiiiiiiii.github.io/Selenium-Driverless/index.html")
        await asyncio.sleep(1)  # Wait for page load

        # Find element
        element = await driver.find_element("xpath",
                                            "//div[@class='wy-menu wy-menu-vertical']//a[@href='api/WebELement.html']")
        if not element:
            print("Element not found")
            return

        print("Testing element.move_to()")
        try:
            await element.move_to()
            print("element.move_to() succeeded")
        except Exception as e:
            print(f"element.move_to() failed: {e}")

        await asyncio.sleep(1)

        print("\nTesting pointer.move_to() with coordinates")
        try:
            # Get element position and size
            location = await element.location
            size = await element.size
            print(f"Location: {location}, Size: {size}")

            # Calculate center
            x = location['x'] + size['width'] // 2
            y = location['y'] + size['height'] // 2
            print(f"Moving to coordinates: {x}, {y}")

            # Move using pointer
            pointer = driver.current_pointer
            await pointer.move_to(x, y)
            print("pointer.move_to() succeeded")
        except Exception as e:
            print(f"pointer.move_to() with coordinates failed: {e}")

        await asyncio.sleep(2)  # Wait to see the result

    finally:
        await driver.quit()


if __name__ == "__main__":
    asyncio.run(test_move_to())

Log:

Testing element.move_to()
element.move_to() failed: '>' not supported between instances of 'int' and 'NoneType'

Testing pointer.move_to() with coordinates
Location: {'x': 0, 'y': 313}, Size: {'height': 30, 'width': 300}
Moving to coordinates: 150, 328
pointer.move_to() succeeded

Process finished with exit code 0
@kaliiiiiiiiii kaliiiiiiiiii added bug Something isn't working unconfirmed a bug which hasn't been reproduced yet labels Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unconfirmed a bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests

2 participants