After launching the application how do I swipe right/left on an android emulator?

Asked by Vinay

 I need to swipe between the screens, i.e. from left to right or vice versa after launching the application.

When i use the command, type(Key.DOWN , KeyModifier.CTRL);

If i am in home screen or in application screen , i am able to swipe from left to right and right to left but if i launch the application and tried to swipe from right to left or viceversa i am not able to perfom a swipe operation.

Note: the application which i am using contains the same header in all screens.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
James Robert (james-robertt9) said :
#2

Hi Vinay,

I am sorry to say this, this is the draw back of the Sikuli tool. We cann't perform swipe operation if header remains same in all the screen/pages.

Regards,
Robert

Revision history for this message
Roman Podolyan (podolyan-roman) said :
#3

Using low-level mouse routines, you can write yourself swipe the way you needed.

Here is example of my quick and dirty right swap routine.

def drag_right():
        # setting begin - end
        x1, y1, x2, y2 = (640, 512, 640, 412)
        start = Location(x1, y1)
        end = Location(x2, y2)

        # moving left
        stepX = 10
        stepY = 0
        run = start
        mouseMove(start); wait(0.5)
        mouseDown(Button.LEFT); wait(0.5)
        for i in range(20):
                run = run.right(stepX).above(stepY)
                mouseMove(run)
                wait(0.1)
        mouseUp()

So, basically:
1) Move mouse to where you want to start a swipe
2) Mouse down
3) Use mouseMove in cycle to to the swipe

Wwhen I did quick flick I increased run in the cycle like this:
        for i in range(5):
                        run = run.right(stepX*i).above(stepY)
                        mouseMove(run)
                        wait(0.05)

Notice that stepX*i — that means that 1st move will be 5 pixels, next 10, then 15 and so on, increasing mouse speed.

Using routines like that, I implemented all the swipes I needed.

Hope that will help you too.

Can you help with this problem?

Provide an answer of your own, or ask Vinay for more information if necessary.

To post a message you must log in.