[eggPlant Functional] Scrolling On Touch Screen Devices

If you’ve been working with touch screen devices such as smart phones or tablets (iPhone, iPod Touch, iPad, or Android), you may be wondering how to scroll (flick) to get to content that’s off the screen.

Very simply, anything that needs to happen with touches (excluding multi-touch gestures) will be accomplished with eggPlant’s mouse commands. So taps/touches are accomplished with the click command, scrolling or something that would require dragging a finger acros the screen would be accomplished using the drag, drop, and/or dragAndDrop commands.

In it’s simplest form, you can use a dragAndDrop to scroll the screen:

dragAndDrop "StartImage", "StopImage"

When capturing images for the start and stop images, it’s best to capture something that doesn’t change, like the carrier name on the iPhone or something in the notification bar on Android and move the hotspot to the start and end positions, so your images might look something like this:

Starting Locatation: http://www.testplant.com/img/forum/PhoneHotspot1.png

Ending Location: http://www.testplant.com/img/forum/PhoneHotspot2.png

You may need to experiment with eggPlant’s Run Options in order to make sure that your drag and drop is not interpreted as a click and hold, particularly on Android devices. You can tweak these options as part of your script.

There are 4 global properties that eggPlant applies when working with mouse movement in this situation.
[list]the remoteWorkInterval. This is the minimum amount of time eggPlant will wait between actions on a system. Measured in seconds
the mouseDragSpeed. This is how fast the mouse moves on drag and is measured in pixels/segment.
the mouseMoveDelay. This is how much eggPlant waits between segments of the drag
dragEndDelay. This one represents a slight delay before the mouse up message.[/list:u]
You can set all but the dragEndDelay in the Run Options of Preferences. But you won’t want to do that, as all 4 of them can be set programmatically during the script. Once you set them, they’re set until the run ends or the settings are changed again.

You will need to experiment with these settings to get the timing right. So what you’ll want to do is first save off the old value for each one:

put the remoteWorkInterval into oldRWI

Then set it to the new one:

put.3 into the remoteWorkInterval

You can set up functions that imitate the behavior by using the above settings and using the drag, drop, and dragAndDrop commands… folding all of the setting and resetting the global prefs and the mouse movements into one package.

If you do find yourself having trouble with your settings, feel free to email support and we’d be happy to help!

Allen Fisher
Sr. Systems Engineer
TestPlant, Inc.

One other point to be made here: In the iOS, there is form of momentum-based scrolling that allows a “flick” to impart motion to something that then gradually slows and stops. EggPlant’s drag and drop motion will trigger this scrolling, which sometimes makes it difficult to find or select a specific item. To counter this you will need to slow down the Mouse Drag Speed setting, possibly to it’s lowest value:

set the mouseDragSpeed to 1

This will cause the mouse to move very slowly when dragging (you may want to switch it back and forth between the default and the overridden value as in Allen’s example), but it makes the scrolling very deliberate and does not impart momentum to items like the scrolling lists of dropdown menus.

This DragAndDrop works perfect on Android.
But on iPhone, it doesn’t work. I tried the following, also tried change other options. But it doesn’t work.

set the mouseDragSpeed to 1
Drag (300,300)
set the mouseDragSpeed to 1
Drop “ios4BackBtn”

set the mouseDragSpeed to 1
DragAndDrop (300,300), “ios4BackBtn”

Setting the MouseDragSpeed to 1 definitely works on the iPhone – the technique and the code were developed using an iPhone. There’s no need to set it more than once in a script – once you’ve set it, it stays set unless you set it to a different value, so the code you posted would just be:

set the mouseDragSpeed to 1
Drag (300,300)
Drop "ios4BackBtn" 

You say that it “doesn’t work” but you don’t say how it doesn’t work or what does happen. I don’t know exactly what you’re trying to accomplish. It would help to have a screen shot with the starting and ending points labeled. If you’re starting in the middle of the screen, I don’t think you want to drag to the back button.

DragAndDrop is functionally equivalent to the separate Drag and Drop commands.

it might be silly but i dont get it.
im trying to do this in contact application on windows mobile 6 pro.
im typing name (first field in a very long list). Then i’d lite to scroll down and type something eg. in last field.
how do i need to capture pictures to performe such thing?

regards,
Tom

When you scroll on a phone, you put your finger/thumb at one location and drag it to another location. When you do this using eggPlant, you can either use images or just coordinates. When scrolling down, you drag down, so you would pick an image closer to the top of the screen for your starting point and end at an image further down the screen. So your code would be something like:

drag "[image near the top]"
drop "[image closer to the bottom]"

or you could just use a couple of coordinates:

drag (50, 10)
drop (50, 100)

If you picture your finger or thumb moving between the two images/points, I think you’ll be able see how this mimics the gesture of scrolling.

Update: we’ve added a number of mobile-specific commands, including those that can perform swiping/scrolling actions. The swipe commands are very easy to use, but if you need some more control over where on the screen the swiping action STOPS, we still recommend using DragandDrop, as the Swipe commands only take a START location parameter.

http://docs.testplant.com/?q=content/mobile-commands-and-functions