How to make swipe position uniform for all devices


I am using below script to perform swipe on device, But when i run same script on second device which has diffrent resolution than first one, swipe behaves differently than first device. Is there any way i can make this script uniform to do swipe on all devices in same manner.

var swipeOpts = {
startX: 100,
startY: 750,
endX: 100,
endY: 30,
duration: 5
.execute(“mobile: swipe”, [swipeOpts]).sleep(9000)


Use % instead of pixels, like

var swipeOpts = {
    startX: 0.2,
    startY: 0.9,
    endX: 0.2,
    endY: 0.05,
   duration: 1

PS: duration 5 seconds, seems like too long for a swipe, no? :slight_smile:

1 Like

I wrote a basic tutorial on element-relative swiping that may be helpful - the problem that you’re having is that your swipe is using absolute positioning, which is going to behave differently on devices with different screen sizes.

By supplying the element you want to execute your swipe on, you can define relative coordinates for your swipe. This should be enough to get you on the right track.