首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Appium-android在本地应用程序中滑动操作

使用Appium-android在本地应用程序中滑动操作
EN

Stack Overflow用户
提问于 2015-10-15 07:28:04
回答 2查看 1.1K关注 0票数 0

几天前我开始学习appium。我的问题是,我想在flipkart应用程序中滑动图像并放大图像。我试过使用下面的代码,但是滑动操作是在同一个页面上执行的,也就是说,在它用x轴和y轴线从右向左移动的同一图像上,缩放操作没有执行。谁能告诉我,请用java代码如何滑动图像和缩放它。

代码下面的 :

代码语言:javascript
复制
driver.findElement(By.className(properties.getProperty("cross_mark_className"))).click();
    System.out.println("clicked on cross mark");
    driver.findElement(By.className(properties.getProperty("home_menu_className"))).click();

    WebElement mobile = driver.scrollTo("Mobiles");
    System.out.println("scroll till Mobiles in home slider menu");
    mobile.click();
    driver.scrollTo("Top Offers!!").click();
    driver.scrollTo("Honor 4x").click();
    delay(4000);
    WebElement honor = driver.findElementById("com.flipkart.android:id/product_list_product_item_image");
    taction.tap(honor);

 driver.swipe(495,484, 52, 484, 12000);
 delay(12000);
 driver.zoom(honor);
 delay(8000);
EN

回答 2

Stack Overflow用户

发布于 2015-10-15 14:06:36

您可以尝试通过使用TouchAction类来执行swipe。

代码语言:javascript
复制
 TouchAction action = new TouchAction(driver).longPress(x,y).moveTo(x, y).release();
 action.perform();
票数 0
EN

Stack Overflow用户

发布于 2015-10-16 09:08:45

您可以尝试为所有移动设备使用这种安全的动态滑动代码:

代码语言:javascript
复制
Dimension dimension = driver.manage().window().getSize();
int width = dimension.getWidth();
int height = dimension.getHeight();
switch(direction)
{
case "right" : driver.swipe((int) (width*(0.20)), (int) (height*(0.50)), (int) (width*(0.80)), (int) (height*(0.50)), 6000);
break;
case "left" : driver.swipe((int) (width*(0.80)), (int) (height*(0.50)), (int) (width*(0.20)), (int) (height*(0.50)), 6000);
break;
case "up" : driver.swipe((int) (width*(0.50)), (int) (height*(0.70)), (int) (width*(0.50)), (int) (height*(0.30)), 6000);
break;
default : driver.swipe((int) (width*(0.50)), (int) (height*(0.30)), (int) (width*(0.50)), (int) (height*(0.70)), 6000);
break;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33142406

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档