I am trying to implement swipe method.May I know what is the correct way to achieve my objective?
public void swipeWithCordinateLocation(WebDriver driver,double startX,
double startY,double endX,double endY,
double Duration)
{
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, Double> swipeObject = new HashMap<String, Double>();
swipeObject.put("x", startX);
swipeObject.put("y", startY);
swipeObject.put("x", endX);
swipeObject.put("y",endY );
swipeObject.put("duration", Duration);
// HashMap[] param = {swipeObject};
js.executeScript("mobile: swipe", swipeObject);
}
common.swipeWithCordinateLocation(driver, 100.00, 500.00, 500.00, 500.00, 1.00);
But appium is perform swipe but it takes different credentials
[x=360][y=592]
to [x=360][y=592]
. what to do? Can any one help me please.
The best solution is to use swipe() of AppiumDriver as shown below:
Swipe Left:
Swipe Right:
You can achieve the same swiping result with TouchAction
Just play with the coordinates to get the desidered swiping.
The best way to analyze a swipe in automation is to enable "Show touches" and "pointer location" options in your developer option.
The correct code for the swipe parameters is this -
Hope this helps.
Or even a better way is to use something like using fractions -
You can also use uiautomator for the same . It will help you to automate test cases very effectively and faster.
you can read more about it at http://developer.android.com/tools/help/uiautomator/index.html