Skip to content
This repository was archived by the owner on Aug 16, 2025. It is now read-only.
This repository was archived by the owner on Aug 16, 2025. It is now read-only.

AttributeError: move_to requires a WebElement #116

@M-Fahad

Description

@M-Fahad

Hello team,

I am just running the example code you provided in the example

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from random import randint
import time
import utilities

driver = utilities.startWebDriverSession('http://localhost:4622/wd/hub')

driver.get("calculator")
time.sleep(10)

driver.add_cookie({'name': 'mouse_speed', 'value': 40})

def clickElement(xPath):
    element = driver.find_element(By.XPATH, xPath)
    ActionChains(driver).move_to_element(element).click().perform()

#AC
clickElement("/AXApplication[@AXTitle='Calculator']/AXWindow[@AXIdentifier='_NS:437' and @AXSubrole='AXStandardWindow']/AXGroup[@AXIdentifier='_NS:336']/AXButton[@AXTitle='6' and @AXIdentifier='_NS:459']")

But receiving the error code mentioned below. Can you please help me to fix this problem?

Traceback (most recent call last):
  File "/Users/upgenics/Desktop/appium-for-mac-master/examples/SeleniumConf April 2017/new.py", line 24, in <module>
    clickElement("/AXApplication[@AXTitle='Calculator']/AXWindow[@AXIdentifier='_NS:437' and @AXSubrole='AXStandardWindow']/AXGroup[@AXIdentifier='_NS:336']/AXButton[@AXTitle='6' and @AXIdentifier='_NS:459']")
  File "/Users/upgenics/Desktop/appium-for-mac-master/examples/SeleniumConf April 2017/new.py", line 21, in clickElement
    ActionChains(driver).move_to_element(element).click().perform()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/common/action_chains.py", line 252, in move_to_element
    self.w3c_actions.pointer_action.move_to(to_element)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/common/actions/pointer_actions.py", line 59, in move_to
    raise AttributeError("move_to requires a WebElement")
AttributeError: move_to requires a WebElement

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