SeeTestAutomation - Drag
Please note that this tool is classified as a Legacy tool. We recommend transitioning to our updated solutions to maintain optimal performance and security in your workflows. For more information on this matter, please reach out to technical support .
**Drag(**Zone, Element, Index, XOffset, YOffset)
Description
Drag an element or text into a specified zone (you can drag the second, third, etc appearance of the element by setting Index to 1, 2, etc)
Parameters
- Zone - Select Zone
- Element - Select Element from drop-down list OR (for OCR text identification) insert text into the empty box in the drop down list
- Index - Element Order (the number of times the element appears more than once)
- XOffset - Horizontal Offset from the Element in screen pixels (negative values are possible, can use P2cx to convert screen percentage to pixels)
- YOffset - Vertical Offset from the Element in screen pixels (negative values are possible, can use P2cy to convert screen percentage to pixels)
Usage
Scenario**:** In the following example, we will use the drag command together with the SeeTestAutomation - SetDragStartDelay command in order to move the Play Storeicon across the device's springboard.
Command usage: We will first use the SetDragStartDelay command in order to press the element for 1000 milliseconds before starting the drag. We will then use the Drag command with the following configurations:
Parameters:
- Zone - will be set to NATIVE
- Element - will be set to xpath=//*[@text='Play Store'] in order to identify the Play Store icon element
- Index - will be set to 0
- XOffset - X drag offset - will be set to 0 .
- YOffset - Y drag offset - will be set to -300.
To drag up/down we set the YOffset +( num of pixels ) for DOWN, and -( num of pixels ) for UP. To drag right/left we set the XOffset +( num of pixels ) for RIGHT , and -( num of pixels ) for LEFT.
- setting XOffset to 0 means no drag in the horizontal direction, the YOffset scenario in analogus.
This will be the result of the sequence:
Code Examples
Java Example Expand source
client.SetDragStartDelay(1000);
client.drag("NATIVE", "xpath=//*[@text='Play Store']", 0, 0, -300);
C# Example Expand source
client.SetDragStartDelay(1000);
client.Drag("NATIVE", "xpath=//*[@text='Play Store']", 0, 0, -300);
VBScript Example Expand source
client.SetDragStartDelay(1000)
client.Drag("NATIVE", "xpath=//*[@text='Play Store']", 0, 0, -300)
Python Example Expand source
self.client.setDragStartDelay(1000)
self.client.drag("NATIVE", "xpath=//*[@text='Play Store']", 0, 0, -300)
Perl Example Expand source
$client->setDragStartDelay(1000);
$client->drag("NATIVE", "xpath=//*[\@text='Play Store']", 0, 0, -300);