Unable to swipe on iOS Simulator using JS

I am currently unable to swipe on an iOS simulator (iPhone 8, 11.3). I initially used Appium desktop v1.8.0 (JS) to record which provided me with TouchAction code:

.touchAction([
{action: ‘press’, x: 306, y: 332},
{action: ‘moveTo’, x: -233, y: 3},
‘release’
])

This didn’t appear to do anything. When I looked at the actual coordinates, it seemed very wrong that it was moving to minus, so I updated it manually:

.touchAction([
{action: ‘press’, x: 320, y: 350},
{action: ‘moveTo’, x: 80, y: 350},
‘release’
])

This also is doing nothing.

I have tried implementing waitforexists and a pause prior to execution of this.

I have tried using swipe and swipeLeft commands which don’t seem to work and also say they are being deprecated (even tried referencing an element beforehand and even XPath which I know is not recommended):
i.e:
.element("~img_icon_bag")
&
.swipe(’//XCUIElementTypeApplication[@name=“xxx”]/XCUIElementTypeWindow[1]’, -200, 0, 2)
.swipeLeft(’//XCUIElementTypeApplication[@name=“xxx”]/XCUIElementTypeWindow[1]’, 2)

Below is my headers:

const wdio = require(‘webdriverio’);
const caps = {“platformName”:“iOS”,“platformVersion”:“11.3”,“deviceName”:“iPhone 8”,“app”:"/Users/xxx/Library/Developer/Xcode/DerivedData/xxx-hlggtgxwuwcrdofzomwyfksiintx/Build/Products/Developer-iphonesimulator/xxx.app",“automationName”:“XCUITest”};
const driver = wdio.remote({
protocol: “http”,
host: “localhost”,
port: 4723,
path: “/wd/hub”,
desiredCapabilities: caps
});

Running the file via terminal:
node test.js
I am not sure what else to try…I read somewhere that it is unable to swipe in a Simulator, but surely that can’t be right?

Appreciate any help!

Are you stuck in a WebView? The other option is to insert a wait between your two actions in your touchAction

Nope, there’s an initial loading screen with a spinner which then moves on to a native page where you can either swipe three times to access a Login/Register page or press a Skip button.

Did you try putting a wait action in between your press and moveTo?

Sorry how would that look?

I’ve tried various different ways of implementing it with no luck, e.g.

.touchAction([
{action: ‘press’, x: 320, y: 350},
‘wait’,
{action: ‘moveTo’, x: 80, y: 350},
‘release’
])

&

{action: ‘wait’, 3000),

The raw appium log shows this (all my tests are java, so not sure entirely):

2018-05-24 16:17:49:321 - [debug] [MJSONWP] Calling AppiumDriver.performTouch() with args: [[{"action":"press","options":{"x":540,"y":1255}},{"action":"wait","options":{"ms":500}},{"action":"moveTo","options":{"x":540,"y":538}},{"action":"release","options":{}}],"60168963-277b-42f7-ac7a-ae9e0e24acb7"]

So maybe try:

.touchAction([
{action: ‘press’, x: 320, y: 350},
{action: ‘wait’, ms: 3000},
{action: ‘moveTo’, x: 80, y: 350},
‘release’
])
2 Likes

Awesome, that worked! Thanks very much for your help!

Perfectly! You helped me a lot! Action - “wait” solved my problem!