滑动方法在android自动化测试中不起作用 [英] Swipe method not working in android automation testing

查看:38
本文介绍了滑动方法在android自动化测试中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实施 swipe 方法.我可以知道实现我的目标的正确方法是什么吗?

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);

但是 appium 是执行 swipe 但它需要不同的凭据

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 way to analyze a swipe in automation is to enable "Show touches" and "pointer location" options in your developer option.

swipe 参数的正确代码是这样的 -

The correct code for the swipe parameters is this -

swipeObject.put("startX", 198.00);
swipeObject.put("startY", 685.00);
swipeObject.put("endX", 198.00);
swipeObject.put("endY", 550.00);
swipeObject.put("duration", 1.0);

希望这会有所帮助.

或者更好的方法是使用诸如使用分数之类的东西 -

Or even a better way is to use something like using fractions -

swipeObject.put("startX", 0.50);
swipeObject.put("startY", 0.50);
swipeObject.put("endX", 0.50);
swipeObject.put("endY", 0.35);
swipeObject.put("duration", 1.0);

这篇关于滑动方法在android自动化测试中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆