android - 使用 Selenium 在 Kobiton 设备上滑动

标签 android selenium testing selenium-webdriver automated-tests

我正在尝试在我的移动自动化测试中从左向右滑动。

我正在使用 selenium 框架打开 Kobiton 上的移动设备,但似乎找不到滑动屏幕的方法。

我尝试过使用:

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("('element').trigger('swipe', {startX: 0.95})");

这是我从另一张票中找到的,但它不起作用。有没有办法在 selenium 中滑动元素或者是否有其他滑动方式?

如果需要更多信息,我很乐意提供帮助。

最佳答案

//Try to create an action
TouchAction action = new TouchAction(driver);

//get location start
int startY = element1.getLocation().getY() + (element1.getSize().getHeight() / 2);
int startX = element1.getLocation().getX() + (element1.getSize().getWidth() / 2);

//get location end
int endX = element2.getLocation().getX() + (element2.getSize().getWidth() / 2);
int endY = element2.getLocation().getY() + (element2.getSize().getHeight() / 2);

//and execute the action
action.press(startX, startY).waitAction(2000).moveTo(endX, endY).release().perform();

关于android - 使用 Selenium 在 Kobiton 设备上滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57957290/

相关文章:

ruby-on-rails - 在 rails 的初始值设定项中,在哪里为这个文件编写测试用例?

android - 在Activity而不是布局上使用dataBinding

c# - 单元测试的 Web 资源

testing - 如何在 Haskell 中使用 SmallCheck?

firefox - 通过 webdriver 控制 Firefox 的最佳方法

python - 使用 webdriver 在 Chrome 中运行 Python

python - 网络驱动程序,Python : How to catch dynamically updating url with the appropriate value and save it to the variable

android - 如何以编程方式在android中添加到主屏幕的快捷方式

android - IOIO-OTG错误,无法编译。包括Logcat

android - 注册一个应用程序以在 SEND 操作中接收所有文件类型