Touch Perform
Perform a touch action sequence //执行触摸动作序列
Example Usage
Java | TouchAction action = new TouchAction(driver); action.press(10, 10); action.moveTo(10, 100); action.release(); action.perform(); |
Python | from appium.webdriver.common.touch_action import TouchAction // … actions = TouchAction(driver) actions.tap_and_hold(20, 20) actions.move_to(10, 100) actions.release() actions.perform() |
Javascript | // webdriver.io example driver.touchPerform([ { action: 'press' , options: { x: 100, y: 250 }},{ action: 'moveTo' , options: { x: 300, y: 100 }},{ action: 'release' }]); // wd example let action = new wd.TouchAction(); action.press({x: 10, y: 10}); action.moveTo({x: 10, y: 100}); action.release(); await action.perform(); |
Ruby | # ruby_lib example touch_action.down(element).move_to(10, 100).up(50, 50).perform # ruby_lib_core example @driver.touch_action.down(element).move_to(10, 100).up(50, 50).perform |
C# | TouchAction action = new TouchAction(driver); action.Press(10, 10); action.MoveTo(10, 100); action.Release(); action.Perform(); |
PHP | // TODO PHP sample |
Description
This functionality is only available from within a native context //此功能仅在本机上下文中可用
‘Touch Perform’ works similarly to the other singular touch interactions, except that this allows you to chain together more than one touch action as one command. This is useful because Appium commands are sent over the network and there’s latency between commands. This latency can make certain touch interactions impossible because some interactions need to be performed in one sequence. Vertical, for example, requires pressing down, moving to a different y coordinate, and then releasing. For it to work, there can’t be a delay between the interactions.
/* Touch Perform”的工作原理与其他单一的触摸交互类似,只是它允许您将多个触摸动作作为一个命令链接在一起。这很有用,因为Appium命令是通过网络发送的,并且命令之间存在延迟。这种延迟会使某些触摸交互变得不可能,因为某些交互需要在一个序列中执行。垂直,例如,需要按下,移动到不同的y坐标,然后释放。为了让它工作,交互之间不能有延迟 */
Support
Appium Server
Platform | Driver | Platform Versions | Appium Version | Driver Version |
---|---|---|---|---|
iOS | XCUITest | 9.3+ | 1.6.0+ | All |
UIAutomation | 8.0 to 9.3+ | All | All | |
Android | Espresso | ?+ | 1.9.0+ | All |
UiAutomator2 | ?+ | 1.6.0+ | All | |
UiAutomator | 4.3+ | All | All | |
Mac | Mac | ?+ | 1.6.4+ | All |
Windows | Windows | 10+ | 1.6.0+ | All |
Appium Clients
Language | Support | Documentation |
---|---|---|
Java | All | appium.github.io |
Python | All | appium.github.io |
Javascript (WebdriverIO) | All | |
Javascript (WD) | All | github.com |
Ruby | All | www.rubydoc.info |
PHP | All | github.com |
C# | All | github.com |
HTTP API Specifications
Endpoint
POST /session/:session_id/touch/perform
URL Parameters
name | description |
---|---|
session_id | ID of the session to route the command to |
JSON Parameters
name | type | description |
---|---|---|
action | string | The type of action to perform (moveTo |
options | object | The parameters of the action |
opts.element | string | The ID of the element |
opts.x | number | The X coordinate of the operation (relative to top left corner) |
opts.y | number | The Y coordinate of the operation (relative to top left corner) |
opts.count | number | Tap count |
Response
null