I’m having trouble using long_press in the python client. I hope I’m doing something silly as I’m new to appium. Any help would be appreciated figuring this out.
The error being returned is {“required”:[“elements”]} and you sent [“sessionId”,“element”] for long_press.
Version’s, Caps and imports
appium 1.6.3
from appium import webdriver
from selenium.webdriver.common.touch_actions import TouchActions
desired_caps = {}
desired_caps[‘platformName’] = ‘iOS’
desired_caps[‘platformVersion’] = platformVersion
desired_caps[‘deviceName’] = deviceName
desired_caps[‘udid’] = udid
desired_caps[‘automationName’] = ‘XCUITest’
desired_caps[‘realDeviceLogger’] = ‘idevicesyslog’
desired_caps[‘app’] = os.path.abspath(app_path)
desired_caps[‘xcodeConfigFile’] = ‘/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/xcodeConfigfile.xcconfig’
desired_caps[‘xcodeSigningId’] = ‘iPhone Developer’
desired_caps[‘newCommandTimeout’] = 10000
Code below is inside a function:
print(“Inside long_press_on_model”)
model = self.driver.find_element_by_id(model_name)
current = self.driver.current_context
print("This is the current driver " + current)
# print("This is the dir of the webElement " + str(dir(model)))
print("this is the model" + str(model))
action = Base.TouchActions(self.driver)
action.long_press(model).perform()
Terminal output:
Inside long_press_on_model
This is the current driver NATIVE_APP
this is the model appium.webdriver.webelement.WebElement (session=“e9c97185-1f75-4870-9e73-9818b96d4e82”, element=“2837406B-2D88-4D82-94E0-49C5EE53FF44”)
Traceback (most recent call last):
File “tests/test.py”, line 44, in
myFunc.long_press_on_model(model)
File “page_models/my_test.py”, line 66, in long_press_on_model
action.long_press(model).perform()
File “/usr/local/lib/python2.7/site-packages/selenium/webdriver/common/touch_actions.py”, line 47, in perform
action()
File “/usr/local/lib/python2.7/site-packages/selenium/webdriver/common/touch_actions.py”, line 151, in
Command.LONG_PRESS, {‘element’: on_element.id}))
File “/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py”, line 236, in execute
self.error_handler.check_response(response)
File “/usr/local/lib/python2.7/site-packages/appium/webdriver/errorhandler.py”, line 29, in check_response
raise wde
selenium.common.exceptions.WebDriverException: Message: Parameters were incorrect. We wanted {“required”:[“elements”]} and you sent [“sessionId”,“element”]
Appium log:
[debug] [MJSONWP] Responding to client with driver.findElement() result: {“ELEMENT”:“2837406B-2D88-4D82-94E0-49C5EE53FF44”,“type”:“XCUIElementTypeStaticText”,“label”:“model”}
[HTTP] <-- POST /wd/hub/session/e9c97185-1f75-4870-9e73-9818b96d4e82/element 200 768 ms - 199
[HTTP] --> GET /wd/hub/session/e9c97185-1f75-4870-9e73-9818b96d4e82/context {}
[debug] [MJSONWP] Calling AppiumDriver.getCurrentContext() with args: [“e9c97185-1f75-4870-9e73-9818b96d4e82”]
[debug] [XCUITest] Executing command ‘getCurrentContext’
[debug] [MJSONWP] Responding to client with driver.getCurrentContext() result: “NATIVE_APP”
[HTTP] <-- GET /wd/hub/session/e9c97185-1f75-4870-9e73-9818b96d4e82/context 200 3 ms - 84
[HTTP] --> POST /wd/hub/session/e9c97185-1f75-4870-9e73-9818b96d4e82/touch/longclick {“sessionId”:“e9c97185-1f75-4870-9e73-9818b96d4e82”,“element”:“2837406B-2D88-4D82-94E0-49C5EE53FF44”}
[debug] [MJSONWP] Bad parameters: BadParametersError: Parameters were incorrect. We wanted {“required”:[“elements”]} and you sent [“sessionId”,“element”]
[HTTP] <-- POST /wd/hub/session/e9c97185-1f75-4870-9e73-9818b96d4e82/touch/longclick 400 2 ms - 99