In mobile app testing, simulating user interactions like swipes, taps, and pinch-zoom gestures is crucial for validating how the app behaves. Gestures are a natural part of mobile app navigation, and Appium provides ways to automate these actions to test the app's usability and responsiveness.
Gestures let you interact with mobile apps like a real user would. Examples include:
- Tapping on buttons or icons.
- Swiping through image galleries, lists, or screens.
- Scrolling down pages or up to the top.
- Pinch and Zoom to zoom in or out on images or maps.
- Long Press for interactions that need a longer touch (e.g., dragging an item).
In the latest versions of Appium, you can also use the W3C Actions API, which provides more flexibility and compatibility with both Android and iOS.
Java
C#
Python
Javascript
Kotlin
PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
Sequence swipe = new Sequence(finger, 1);
swipe.addAction(finger.createPointerMove(Duration.ZERO, PointerInput.Origin.viewport(), startX, startY));
swipe.addAction(finger.createPointerDown(PointerInput.MouseButton.LEFT.asArg()));
swipe.addAction(finger.createPointerMove(Duration.ofMillis(1000), PointerInput.Origin.viewport(), endX, endY));
swipe.addAction(finger.createPointerUp(PointerInput.MouseButton.LEFT.asArg()));
driver.perform(Arrays.asList(swipe));
// Create touch input (finger)
var finger = new PointerInputDevice(PointerKind.Touch);
// Create action sequence
var swipe = new ActionSequence(finger, 0);
// Move finger to start point
swipe.AddAction(finger.CreatePointerMove(TimeSpan.Zero, CoordinateOrigin.Viewport, startX, startY, TimeSpan.Zero));
// Finger down (touch press)
swipe.AddAction(finger.CreatePointerDown(MouseButton.Left));
// Move to end point (swipe)
swipe.AddAction(finger.CreatePointerMove(TimeSpan.FromMilliseconds(1000), CoordinateOrigin.Viewport, endX, endY));
// Finger up (release)
swipe.AddAction(finger.CreatePointerUp(MouseButton.Left));
// Perform action
driver.PerformActions(new List<ActionSequence> { swipe });
# Describes the input device being used for the action.
finger = PointerInput("touch", "finger")
actions = ActionBuilder(driver)
# Add a new pointer input device to the action builder.
actions.add_pointer_input(finger)
# Move finger to start point
actions.pointer_action.move_to_location(startX, startY)
# Finger down (touch press)
actions.pointer_action.pointer_down()
# Move to end point (swipe)
actions.pointer_action.move_to_location(endX, endY, duration=1000)
# Finger up (release)
actions.pointer_action.pointer_up()
# Perform action
actions.perform()
const driver = await remote({capabilities : wdOpts});
const finger = {
type: 'pointer',
id: 'finger1',
parameters: { pointerType: 'touch' },
actions: [
{ type: 'pointerMove', duration: 0, x: startX, y: startY },
{ type: 'pointerDown', button: 0 },
{ type: 'pointerMove', duration: 1000, x: endX, y: endY },
{ type: 'pointerUp', button: 0 }
]
};
await driver.performActions([finger]);
// Optional cleanup
await driver.releaseActions();
// Create touch input (finger)
val finger = PointerInput(PointerInput.Kind.TOUCH, "finger")
// Create sequence
val swipe = Sequence(finger, 1)
// Move to start position
swipe.addAction(finger.createPointerMove(Duration.ZERO, PointerInput.Origin.viewport(), startX, startY))
// Finger down
swipe.addAction(finger.createPointerDown(PointerInput.MouseButton.LEFT.asArg()))
// Move to end position (swipe)
swipe.addAction(finger.createPointerMove(Duration.ofMillis(1000), PointerInput.Origin.viewport(), endX, endY ))
// Finger up
swipe.addAction(finger.createPointerUp(PointerInput.MouseButton.LEFT.asArg()))
// Perform the action
driver.perform(listOf(swipe))
This approach is more versatile and works on both platforms without requiring separate Android or iOS-specific code.
Appium also lets you perform gestures using the execute command, which gives you more control compared to normal gesture methods. With executeScript("mobile: ..."), you can directly call built-in mobile actions like swipe, scroll, pinch, or long press. These commands work at a lower level and are useful when regular methods don't work properly or when you need more precise control over gestures. For example, you can use mobile: swipeGesture or mobile: pinchOpenGesture to perform advanced interactions. This approach is especially helpful in Appium 2.x, where many modern gesture actions are exposed through execute commands.
Following are some of the gesture commands.
Java
C#
Python
Javascript
Kotlin
WebElement clickGestureElement = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: clickGesture", Map.ofEntries(
entry("elementId", ((RemoteWebElement) clickGestureElement).getId()),
entry("x", 100),
entry("y", 100)
));
IWebElement clickGestureElement = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: clickGesture", new Dictionary<string, object> {
{ "elementId", ((AppiumElement)clickGestureElement).Id },
{ "x", 100 },
{ "y", 100 }
});
clickElem = driver.find_element(AppiumBy.XPATH, "//element")
driver.execute_script('mobile: clickGesture', {
'elementId' : clickElem.id,
'x': 100,
'y': 100
})
let clickGestureElement = driver.$("//element")
await driver.execute("mobile: clickGesture", {
elementId : clickGestureElement.elementId,
x : 100,
y : 100
});
val clickGestureElement = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: clickGesture", Map.ofEntries(
Map.entry<String?, String?>("elementId", (clickGestureElement as RemoteWebElement).getId()),
Map.entry<String?, Int?>("x", 100),
Map.entry<String?, Int?>("y", 100)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement longClickGestureElement = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: longClickGesture", Map.ofEntries(
entry("elementId", ((RemoteWebElement) longClickGestureElement).getId()),
entry("x", 100),
entry("y", 100),
entry("duration", 1000)
));
IWebElement longClickGestureElement = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: longClickGesture", new Dictionary<string, object> {
{ "elementId", ((AppiumElement)longClickGestureElement).Id },
{ "x", 100 },
{ "y", 100 },
{ "duration", 1000}
});
longClickElem = driver.find_element(AppiumBy.XPATH, "//element")
driver.execute_script('mobile: longClickGesture', {
"elementId" : longClickElem.id,
'x': 100,
'y': 100,
'duration': 1000
})
let longClickGestureElement = driver.$("//element")
await driver.execute("mobile: longClickGesture", {
elementId : longClickGestureElement.elementId,
x : 100,
y : 100,
duration : 1000
});
val longClickGestureElement = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: longClickGesture", Map.ofEntries(
Map.entry<String?, String?>("elementId", (longClickGestureElement as RemoteWebElement).getId()),
Map.entry<String?, Int?>("x", 100),
Map.entry<String?, Int?>("y", 100),
Map.entry<String?, Int?>("duration", 1000)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement doubleClickGestureElement = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: doubleClickGesture", Map.ofEntries(
entry("elementId", ((RemoteWebElement) doubleClickGestureElement).getId()),
entry("x", 100),
entry("y", 100)
));
IWebElement doubleClickGestureElement = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: doubleClickGesture", new Dictionary<string, object> {
{ "elementId", ((AppiumElement)doubleClickGestureElement).Id },
{ "x", 100 },
{ "y", 100 }
});
dbClickElem = driver.find_element(AppiumBy.XPATH, "//element")
driver.execute_script('mobile: doubleClickGesture', {
"elementId" : dbClickElem.id,
'x': 100,
'y': 100
})
let doubleClickGestureElement = driver.$("//element")
await driver.execute("mobile: doubleClickGesture", {
elementId : doubleClickGestureElement.elementId,
x : 100,
y : 100
});
val doubleClickGestureElement = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: doubleClickGesture", Map.ofEntries(
Map.entry<String?, String?>("elementId", (doubleClickGestureElement as RemoteWebElement).getId()),
Map.entry<String?, Int?>("x", 100),
Map.entry<String?, Int?>("y", 100)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement dragElem = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: dragGesture", Map.ofEntries(
entry("elementId", ((RemoteWebElement) dragElem).getId()),
entry("startX", 100),
entry("startY", 100),
entry("endX", 100),
entry("endY", 100),
entry("speed", 3000)
));
IWebElement dragElem = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: dragGesture", new Dictionary<string, object> {
{ "elementId", ((AppiumElement)dragElem).Id },
{ "startX", 100 },
{ "startY", 100 },
{ "endX", 100 },
{ "endY", 100 },
{ "speed", 3000}
});
dragElem = driver.find_element(AppiumBy.XPATH, "//element")
driver.execute_script("mobile: dragGesture", {
"elementId" : dragElem.id,
"endX" : 500,
"endY" : 1000,
"speed": 3000
})
let dragElem = driver.$("//element")
await driver.execute("mobile: dragGesture", {
elementId : dragElem.elementId,
startX : 100,
startY : 100,
endX : 100,
endY : 100,
speed : 3000
});
val dragElem = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: dragGesture", Map.ofEntries(
Map.entry<String?, String?>("elementId", (dragElem as RemoteWebElement).getId()),
Map.entry<String?, Int?>("startX", 100),
Map.entry<String?, Int?>("startY", 100),
Map.entry<String?, Int?>("endX", 100),
Map.entry<String?, Int?>("endY", 100),
Map.entry<String?, Int?>("speed", 3000)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement flingElem = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: flingGesture", Map.ofEntries(
entry("elementId", ((RemoteWebElement) flingElem).getId()),
entry("direction", "down"),
entry("left", 0),
entry("top", 0),
entry("width", 500),
entry("height", 1000),
entry("speed", 5000)
));
IWebElement flingElem = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: flingGesture", new Dictionary<string, object> {
{ "elementId", ((AppiumElement)flingElem).Id },
{ "direction", "down" },
{ "left", 0 },
{ "top", 0 },
{ "width", 500 },
{ "height", 1000 },
{ "speed", 5000}
});
flingElem = driver.find_element(AppiumBy.XPATH, "(//element")
driver.execute_script("mobile: flingGesture", {
"elementId" : flingElem.id,
"direction" : "down",
"speed" : 5000,
"left" : 0,
"top" : 0,
"width" : 500,
"height" : 1000
})
let flingElem = driver.$("//element")
await driver.execute("mobile: flingGesture", {
elementId : flingElem.elementId,
direction : down,
left : 0,
top : 0,
width : 500,
height : 1000,
speed : 5000
});
val flingElem = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: flingGesture", Map.ofEntries(
Map.entry<String?, String?>("elementId", (flingElem as RemoteWebElement).getId()),
Map.entry<String?, String?>("direction", "down"),
Map.entry<String?, Int?>("left", 0),
Map.entry<String?, Int?>("top", 0),
Map.entry<String?, Int?>("width", 500),
Map.entry<String?, Int?>("height", 1000),
Map.entry<String?, Int?>("speed", 5000)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement pinchOElem = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: pinchOpenGesture", Map.ofEntries(
entry("elementId", ((RemoteWebElement) pinchOElem).getId()),
entry("direction", "down"),
entry("percent", 0.75),
entry("left", 100),
entry("top", 100),
entry("width", 500),
entry("height", 1000),
entry("speed", 3000)
));
IWebElement pinchOElem = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: pinchOpenGesture", new Dictionary<string, object> {
{ "elementId", ((AppiumElement)pinchOElem).Id },
{ "direction", "down" },
{ "percent", 0.75},
{ "left", 100 },
{ "top", 100 },
{ "width", 500 },
{ "height", 1000 },
{ "speed", 3000}
});
pinchOElem = driver.find_element(AppiumBy.XPATH, "(//element")
driver.execute_script('mobile: pinchOpenGesture', {
'elementId': pinchOElem.id,
'percent': 0.75,
'left':100,
'top':100,
'width':500,
'height':1000,
'speed': 3000
})
let pinchOElem = driver.$("//element")
await driver.execute("mobile: pinchOpenGesture", {
elementId : pinchOElem.elementId,
direction : "down",
percent : 0.75,
eft : 100,
top : 100,
width : 500,
height : 1000,
speed : 3000
});
val pinchOElem = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: pinchOpenGesture", Map.ofEntries(
Map.entry<String?, String?>("elementId", (pinchOElem as RemoteWebElement).getId()),
Map.entry<String?, String?>("direction", "down"),
Map.entry<String?, Double?>("percent", 0.75),
Map.entry<String?, Int?>("left", 100),
Map.entry<String?, Int?>("top", 100),
Map.entry<String?, Int?>("width", 500),
Map.entry<String?, Int?>("height", 1000),
Map.entry<String?, Int?>("speed", 3000)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement pinchCElem = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: pinchCloseGesture", Map.ofEntries(
entry("elementId", ((RemoteWebElement) pinchCElem).getId()),
entry("direction", "down"),
entry("percent", 0.75),
entry("left", 100),
entry("top", 100),
entry("width", 500),
entry("height", 1000),
entry("speed", 3000)
));
IWebElement pinchCElem = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: pinchCloseGesture", new Dictionary<string, object> {
{ "elementId", ((AppiumElement)pinchCElem).Id },
{ "direction", "down" },
{ "percent", 0.75},
{ "left", 100 },
{ "top", 100 },
{ "width", 500 },
{ "height", 1000 },
{ "speed", 3000}
});
pinchCElem = driver.find_element(AppiumBy.XPATH, "(//element")
driver.execute_script('mobile: pinchCloseGesture', {
'elementId': pinchCElem.id,
'percent': 0.75,
'left':100,
'top':100,
'width':500,
'height':1000,
'speed': 3000
})
let pinchCElem = driver.$("//element")
await driver.execute("mobile: pinchCloseGesture", {
elementId : pinchCElem.elementId,
direction : "down",
percent : 0.75,
left : 100,
top : 100,
width : 500,
height : 1000 ,
speed : 3000
});
val pinchCElem = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: pinchCloseGesture", Map.ofEntries(
Map.entry<String?, String?>("elementId", (pinchCElem as RemoteWebElement).getId()),
Map.entry<String?, String?>("direction", "down"),
Map.entry<String?, Double?>("percent", 0.75),
Map.entry<String?, Int?>("left", 100),
Map.entry<String?, Int?>("top", 100),
Map.entry<String?, Int?>("width", 500),
Map.entry<String?, Int?>("height", 1000),
Map.entry<String?, Int?>("speed", 3000)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement swipeElem = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: swipeGesture", Map.ofEntries(
entry("elementId", ((RemoteWebElement) swipeElem).getId()),
entry("direction", "up"),
entry("percent", 0.75),
entry("left", 100),
entry("top", 100),
entry("width", 200),
entry("height", 200)
));
IWebElement swipeElem = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: swipeGesture", new Dictionary<string, object> {
{ "elementId", ((AppiumElement)swipeElem).Id },
{ "direction", "up" },
{ "percent", 0.75 },
{ "left", 100 },
{ "top", 100 },
{ "width", 200 },
{ "height", 200 }
});
swipeElem = driver.find_element(AppiumBy.XPATH, "(//element")
driver.execute_script("mobile: swipeGesture", {
"elementId" : swipeElem.id,
"direction" : "up",
"percent" : 0.30,
"left" : 100,
"top" : 500,
"width" : 200,
"height" : 200,
"Speed" : 3000
})
let swipeElem = driver.$("//element")
await driver.execute("mobile: swipeGesture", {
elementId : swipeElem.elementId,
direction : "up",
percent : 0.75,
left : 100,
top : 100,
width : 200,
height : 200
});
val swipeElem = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: swipeGesture", Map.ofEntries(
Map.entry<String?, String?>("elementId", (swipeElem as RemoteWebElement).getId()),
Map.entry<String?, String?>("direction", "up"),
Map.entry<String?, Double?>("percent", 0.75),
Map.entry<String?, Int?>("left", 100),
Map.entry<String?, Int?>("top", 100),
Map.entry<String?, Int?>("width", 200),
Map.entry<String?, Int?>("height", 200)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement scrollElem = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: scrollGesture", Map.ofEntries(
entry("elementId", ((RemoteWebElement) scrollElem).getId()),
entry("direction", "up"),
entry("percent", 0.30),
entry("left", 100),
entry("top", 100),
entry("width", 200),
entry("height", 200),
entry("speed", 3000)
));
IWebElement scrollElem = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: scrollGesture", new Dictionary<string, object> {
{ "elementId", ((AppiumElement)scrollElem).Id },
{ "direction", "up" },
{ "percent", 0.30 },
{ "left", 100 },
{ "top", 100 },
{ "width", 200 },
{ "height", 200 },
{ "speed", 3000 }
});
scrollElem = driver.find_element(AppiumBy.XPATH, "(//element")
driver.execute_script("mobile: scrollGesture", {
"elementId" : scrollElem.id,
"direction" : "up",
"percent" : 0.30,
"left" : 100,
"top" : 500,
"width" : 200,
"height" : 200,
"Speed" : 3000
})
let scrollElem = driver.$("//element")
await driver.execute("mobile: scrollGesture", {
elementId : scrollElem.elementId,
direction : "up",
percent : 0.30,
left : 100,
top : 100,
width : 200,
height : 200,
speed : 3000
});
val scrollElem = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: scrollGesture", Map.ofEntries(
Map.entry<String?, String?>("elementId", (scrollElem as RemoteWebElement).getId()),
Map.entry<String?, String?>("direction", "up"),
Map.entry<String?, Double?>("percent", 0.30),
Map.entry<String?, Int?>("left", 100),
Map.entry<String?, Int?>("top", 100),
Map.entry<String?, Int?>("width", 200),
Map.entry<String?, Int?>("height", 200),
Map.entry<String?, Int?>("speed", 3000)
)
)
Java
C#
Python
Javascript
Kotlin
driver.executeScript("mobile: swipe", Map.ofEntries(
entry("direction", "up"),
entry("percent", 0.30),
entry("velocity", 2500)
));
driver.ExecuteScript("mobile: swipe", new Dictionary<string, object> {
{ "direction", "up" },
{ "percent", 0.30 },
{ "velocity", 2500}
});
driver.execute_script("mobile: swipe", {
"direction" : "up",
"percent" : 0.30,
"velocity" : 2500,
})
await driver.execute("mobile: swipe", {
direction : "up" ,
percent : 0.30 ,
velocity : 2500
});
driver.executeScript(
"mobile: swipe", Map.ofEntries(
Map.entry<String?, String?>("direction", "up"),
Map.entry<String?, Double?>("percent", 0.30),
Map.entry<String?, Int?>("velocity", 2500)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement scrollElement = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: scroll", Map.ofEntries(
entry("elementId", ((RemoteWebElement) scrollElement).getId()),
entry("direction", "down")
));
IWebElement scrollElement = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: scroll", new Dictionary<string, object> {
{ "elementId", ((AppiumElement)scrollElement).Id },
{ "driection", "down" }
});
scrollElementId = driver.find_element(AppiumBy.XPATH, "//element")
driver.execute_script("mobile: scroll", {
"elementId" : scrollElementId.id,
"direction" : "down"
})
let scrollElement = driver.$("//element")
await driver.execute("mobile: scroll", {
elementId : scrollElement.elementId,
driection :"down"
});
val scrollElement = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: scroll", Map.ofEntries<String?, String?>(
Map.entry<String?, String?>("elementId", (scrollElement as RemoteWebElement).getId()),
Map.entry<String?, String?>("direction", "down")
)
)
Java
C#
Python
Javascript
Kotlin
WebElement pinchElement = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: pinch", Map.ofEntries(
entry("elementId", ((RemoteWebElement) pinchElement).getId()),
entry("scale", 2),
entry("velocity", 1.0)
));
IWebElement pinchElement = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: pinch", new Dictionary<string, object> {
{ "elementId", ((AppiumElement)pinchElement).Id },
{ "scale", 2 },
{ "velocity", 1.0 }
});
pinchCElem = driver.find_element(AppiumBy.XPATH, "//element")
driver.execute_script("mobile: pinch", {
"elementId" : pinchCElem.id,
"scale" : 2,
"velocity" : 1.0
})
let pinchElement = driver.$("//element")
await driver.execute("mobile: pinch", {
elementId : pinchElement.elementId,
scale : 2,
velocity : 1.0
});
val pinchElement = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: pinch", Map.ofEntries(
Map.entry<String?, String?>("elementId", (pinchElement as RemoteWebElement).getId()),
Map.entry<String?, Int?>("scale", 2),
Map.entry<String?, Double?>("velocity", 1.0)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement tapElement = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: tap", Map.ofEntries(
entry("elementId", ((RemoteWebElement) tapElement).getId()),
entry("x", 1),
entry("y", 1)
));
IWebElement tapElement = driver.FindElement(MobileBy.Id("element"));
driver.ExecuteScript("mobile: tap", new Dictionary<string, object> {
{ "element", ((AppiumElement) tapElement).Id },
{ "x", 1 },
{ "y", 1 }
});
button = driver.find_element(AppiumBy.XPATH, "//element")
driver.execute_script("mobile: tap", {
"x" : 1,
"y": 1 ,
"element" : button.id
})
let tapElement = driver.$("//element")
await driver.execute("mobile: tap", {
element : tapElement.elementId,
x : 1,
y : 1
});
val tapElement = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: tap", Map.ofEntries(
Map.entry<String?, String?>("element", (tapElement as RemoteWebElement).getId()),
Map.entry<String?, Int?>("x", 1),
Map.entry<String?, Int?>("y", 1)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement dblTapElement = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: doubleTap", Map.ofEntries(
entry("elementId", ((RemoteWebElement) dblTapElement).getId()),
entry("x", 1),
entry("y", 1)
));
IWebElement dblTapElement = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: doubleTap", new Dictionary<string, object> {
{ "elementId", ((AppiumElement) dblTapElement).Id },
{ "x", 1 },
{ "y", 1 }
});
button = driver.find_element(AppiumBy.XPATH, "//element")
driver.execute_script("mobile: doubleTap", {
"x" : 1,
"y": 1 ,
"element" : button.id
})
let dblTapElement = driver.$("//element")
await driver.execute("mobile: doubleTap", {
elementId : dblTapElement.elementId,
x : 1,
y : 1
});
val dblTapElement = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: doubleTap", Map.ofEntries(
Map.entry<String?, String?>("elementId", (dblTapElement as RemoteWebElement).getId()),
Map.entry<String?, Int?>("x", 1),
Map.entry<String?, Int?>("y", 1)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement longTapElem = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: touchAndHold", Map.ofEntries(
entry("elementId", ((RemoteWebElement) longTapElem).getId()),
entry("duration", 2.0),
entry("x", 1),
entry("y", 1)
));
IWebElement longTapElem = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: touchAndHold", new Dictionary<string, object> {
{ "elementId", ((AppiumElement) longTapElem).Id },
{ "duration", 2.0 },
{ "x", 1 },
{ "y", 1 }
});
longTapElem = driver.find_element(AppiumBy.XPATH, "//element")
driver.execute_script("mobile: touchAndHold", {
"elementId" : longTapElem.id,
"duration" : 2.0,
"x": 1,
"y": 1
})
let longTapElem = driver.$("//element")
await driver.execute("mobile: touchAndHold", {
elementId : longTapElem.elementId,
duration : 2.0,
x : 1,
y : 1
});
val longTapElem = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: touchAndHold", Map.ofEntries(
Map.entry<String?, String?>("elementId", (longTapElem as RemoteWebElement).getId()),
Map.entry<String?, Double?>("duration", 2.0),
Map.entry<String?, Int?>("x", 1),
Map.entry<String?, Int?>("y", 1)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement twoFingerTapElem = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: twoFingerTap", Map.ofEntries(
entry("elementId", ((RemoteWebElement) twoFingerTapElem).getId())
));
IWebElement twoFingerTapElem = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: twoFingerTap", new Dictionary<string, object> {
{ "elementId", ((AppiumElement) twoFingerTapElem).Id }
});
twoFingerTapElem = driver.find_element(AppiumBy.XPATH, "//element")
driver.execute_script("mobile: twoFingerTap", {
"elementId" : twoFingerTapElem.id,
})
let twoFingerTapElem = driver.$("//element")
await driver.execute("mobile: twoFingerTap", {
elementId : twoFingerTapElem.elementId
});
val twoFingerTapElem = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: twoFingerTap", Map.ofEntries<String?, String?>(
Map.entry<String?, String?>("elementId", (twoFingerTapElem as RemoteWebElement).getId())
)
)
Java
C#
Python
Javascript
Kotlin
WebElement dragFromToDurationElem = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: dragFromToDuration", Map.ofEntries(
entry("elementId", ((RemoteWebElement) dragFromToDurationElem).getId()),
entry("duration", 2.0),
entry("fromX", 100),
entry("fromY", 100),
entry("toX", 200),
entry("toY", 300)
));
IWebElement dragFromToDurationElem = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: dragFromToDuration", new Dictionary<string, object> {
{ "elementId", ((AppiumElement) dragFromToDurationElem).Id },
{ "duration", 2.0 },
{ "fromX", 100 },
{ "fromY", 100 },
{ "toX", 200 },
{ "toY", 300 }
});
dragFromToDurationElem = driver.find_element(AppiumBy.XPATH, "//element")
driver.execute_script("mobile: dragFromToDuration", {
"elementId" : dragFromToDurationElem.id,
"duration" : 2.0,
"fromX" : 100,
"fromY" : 100,
"toX" : 200,
"toY" : 300
})
let dragFromToDurationElem = driver.$("//element")
await driver.execute("mobile: dragFromToDuration", {
elementId : dragFromToDurationElem.elementId,
duration : 2.0,
fromX : 100,
fromY : 100,
toX : 200,
toY : 300
});
val dragFromToDurationElem = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: dragFromToDuration", Map.ofEntries(
Map.entry<String?, String?>("elementId", (dragFromToDurationElem as RemoteWebElement).getId()),
Map.entry<String?, Double?>("duration", 2.0),
Map.entry<String?, Int?>("fromX", 100),
Map.entry<String?, Int?>("fromY", 100),
Map.entry<String?, Int?>("toX", 200),
Map.entry<String?, Int?>("toY", 300)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement dragFromWithVelocityElem = driver.findElement(AppiumBy.id("elementId"));
WebElement dragToWithVelocityElem = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: dragFromToWithVelocity", Map.ofEntries(
entry("fromElementId", ((RemoteWebElement) dragFromWithVelocityElem).getId()),
entry("toElementId", ((RemoteWebElement) dragToWithVelocityElem).getId()),
entry("pressDuration", 0.5),
entry("holdDuration", 0.1),
entry("velocity", 400),
entry("fromX", 100),
entry("fromY", 100),
entry("toX", 200),
entry("toY", 300)
));
IWebElement dragFromWithVelocityElem = driver.FindElement(MobileBy.Id("elementId"));
IWebElement dragToWithVelocityElem = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: dragFromToWithVelocity", new Dictionary<string, object> {
{ "fromElementId", ((AppiumElement) dragFromWithVelocityElem).Id },
{ "toElementId", ((AppiumElement) dragToWithVelocityElem).Id },
{ "pressDuration", 0.5 },
{ "holdDuration", 0.1 },
{ "velocity", 400 },
{ "fromX", 100 },
{ "fromY", 100 },
{ "toX", 200 },
{ "toY", 300 }
});
dragFromWithVelocityElem = driver.find_element(AppiumBy.XPATH, "//fromElement")
dragToWithVelocityElem = driver.find_element(AppiumBy.XPATH, "//toElement")
driver.execute_script("mobile: dragFromToWithVelocity", {
"fromElementId" : dragFromWithVelocityElem.id,
"toElementId" : dragToWithVelocityElem.id,
"pressDuration" : 0.5,
"holdDuration" : 0.1,
"velocity" : 400,
"fromX" : 100,
"fromY" : 100,
"toX" : 200,
"toY" : 300
})
let dragFromWithVelocityElem = driver.$("//element");
let dragToWithVelocityElem = driver.$("//element");
await driver.execute("mobile: dragFromToWithVelocity", {
fromElementId : dragFromWithVelocityElem.Id,
toElementId : dragToWithVelocityElem.Id,
pressDuration : 0.5,
holdDuration : 0.1,
velocity : 400,
fromX : 100,
fromY : 100,
toX : 200,
toY : 300
});
val dragFromWithVelocityElem = driver.findElement(AppiumBy.id("locatorId"))
val dragToWithVelocityElem = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: dragFromToWithVelocity", Map.ofEntries(
Map.entry<String?, String?>("fromElementId", (dragFromWithVelocityElem as RemoteWebElement).getId()),
Map.entry<String?, String?>("toElementId", (dragToWithVelocityElem as RemoteWebElement).getId()),
Map.entry<String?, Double?>("pressDuration", 0.5),
Map.entry<String?, Double?>("holdDuration", 0.1),
Map.entry<String?, Int?>("velocity", 400),
Map.entry<String?, Int?>("fromX", 100),
Map.entry<String?, Int?>("fromY", 100),
Map.entry<String?, Int?>("toX", 200),
Map.entry<String?, Int?>("toY", 300)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement rotateElem = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: rotateElement", Map.ofEntries(
entry("elementId", ((RemoteWebElement) rotateElem).getId()),
entry("rotation", -Math.PI / 2),
entry("velocity", Math.PI / 4)
));
IWebElement rotateElem = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: rotateElement", new Dictionary<string, object> {
{ "elementId", ((AppiumElement) rotateElem).Id },
{ "rotation", - Math.PI / 2 },
{ "velocity", Math.PI / 4 }
});
rotateElem = driver.find_element(AppiumBy.XPATH, "//element")
driver.execute_script("mobile: rotateElement", {
"elementId" : rotateElem.id,
"rotation" : -math.pi / 2,
"velocity" : math.pi / 4
})
let rotateElem = driver.$("//element")
await driver.execute("mobile: rotateElement", {
elementId : rotateElem.elementId,
rotation : - Math.PI / 2,
velocity : Math.PI / 4
});
val rotateElem = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: rotateElement", Map.ofEntries(
Map.entry<String?, String?>("elementId", (rotateElem as RemoteWebElement).getId()),
Map.entry<String?, Double?>("rotation", -Math.PI / 2),
Map.entry<String?, Double?>("velocity", Math.PI / 4)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement noTapsElem = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: tapWithNumberOfTaps", Map.ofEntries(
entry("elementId", ((RemoteWebElement) noTapsElem).getId()),
entry("numberOfTaps", 2),
entry("numberOfTouches", 1)
));
IWebElement noTapsElem = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: tapWithNumberOfTaps", new Dictionary<string, object> {
{ "elementId", ((AppiumElement) noTapsElem).Id },
{ "numberOfTaps", 2 },
{ "numberOfTouches", 1 }
});
noTapsElem = driver.find_element(AppiumBy.XPATH, "//element")
driver.execute_script("mobile: tapWithNumberOfTaps", {
"elementId" : noTapsElem.id,
"numberOfTaps" : 2,
"numberOfTouches" : 1
})
let noTapsElem = driver.$("//element")
await driver.execute("mobile: tapWithNumberOfTaps", {
elementId : noTapsElem.elementId,
numberOfTaps : 2,
numberOfTouches : 1
});
val noTapsElem = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: tapWithNumberOfTaps", Map.ofEntries(
Map.entry<String?, String?>("elementId", (noTapsElem as RemoteWebElement).getId()),
Map.entry<String?, Int?>("numberOfTaps", 2),
Map.entry<String?, Int?>("numberOfTouches", 1)
)
)
Java
C#
Python
Javascript
Kotlin
WebElement scrollToElem = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: scrollToElement", Map.ofEntries(
entry("elementId", ((RemoteWebElement) scrollToElem).getId())
));
IWebElement scrollToElem = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: scrollToElement", new Dictionary<string, object> {
{ "elementId", ((AppiumElement) scrollToElem).Id }
});
scrollToElem = driver.find_element(AppiumBy.XPATH, "//element")
driver.execute_script("mobile: scrollToElement", {
"elementId" : scrollToElem.id
})
let scrollToElem = driver.$("//element")
await driver.execute("mobile: scrollToElement", {
elementId : scrollToElem.elementId
});
val scrollToElem = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: scrollToElement", Map.ofEntries<String?, String?>(
Map.entry<String?, String?>("elementId", (scrollToElem as RemoteWebElement).getId())
)
)
Java
C#
Python
Javascript
Kotlin
WebElement selectPickerWheelValueElem = driver.findElement(AppiumBy.id("elementId"));
driver.executeScript("mobile: selectPickerWheelValue", Map.ofEntries(
entry("elementId", ((RemoteWebElement) selectPickerWheelValueElem).getId()),
entry("order", "next"),
entry("offset", 0.15)
));
IWebElement selectPickerWheelValueElem = driver.FindElement(MobileBy.Id("elementId"));
driver.ExecuteScript("mobile: selectPickerWheelValue", new Dictionary<string, object> {
{ "elementId", ((AppiumElement) selectPickerWheelValueElem).Id },
{ "order", "next" },
{ "offset", 0.15 }
});
selectPickerWheelValueElem = driver.find_element(AppiumBy.XPATH, "//element")
driver.execute_script("mobile: selectPickerWheelValue", {
"elementId" : selectPickerWheelValueElem.id,
"order" : "next", # or previous
"offset" : 0.15
})
let selectPickerWheelValueElem = driver.$("//element")
await driver.execute("mobile: selectPickerWheelValue", {
elementId : selectPickerWheelValueElem.elementId,
order : "next",
offset : 0.15
});
val selectPickerWheelValueElem = driver.findElement(AppiumBy.id("locatorId"))
driver.executeScript(
"mobile: selectPickerWheelValue", Map.ofEntries(
Map.entry<String?, String?>("elementId", (selectPickerWheelValueElem as RemoteWebElement).getId()),
Map.entry<String?, String?>("order", "next"),
Map.entry<String?, Double?>("offset", 0.15)
)
)
Java
C#
Python
Javascript
Kotlin
driver.executeScript("mobile: alert", Map.ofEntries(
entry("action", "accept"),
entry("buttonLabel", "Cool Button")
));
driver.ExecuteScript("mobile: alert", new Dictionary<string, object> {
{ "action", "accept" },
{ "buttonLabel", "Cool Button" }
});
driver.execute_script("mobile: alert", {
"action" : "accept", # dismiss, getButtons
"buttonLabel" : "Cool Button"
})
await driver.execute("mobile: alert", {
action : accept,
buttonLabel : "Cool Button"
});
driver.executeScript(
"mobile: alert", Map.ofEntries<String?, String?>(
Map.entry<String?, String?>("action", "accept"),
Map.entry<String?, String?>("buttonLabel", "Cool Button")
)
)