appium / appium-for-mac

[deprecated] Application for automating a mac app with JSON wire protocol
Apache License 2.0
194 stars 70 forks source link

AttributeError: move_to requires a WebElement #116

Open M-Fahad opened 1 year ago

M-Fahad commented 1 year ago

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
eglitise commented 1 year ago

This driver is not supported anymore. Consider switching to appium-mac2-driver.