几天前我开始学习appium。我的问题是,我想在flipkart应用程序中滑动图像并放大图像。我试过使用下面的代码,但是滑动操作是在同一个页面上执行的,也就是说,在它用x轴和y轴线从右向左移动的同一图像上,缩放操作没有执行。谁能告诉我,请用java代码如何滑动图像和缩放它。
代码下面的 :
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);发布于 2015-10-15 14:06:36
您可以尝试通过使用TouchAction类来执行swipe。
TouchAction action = new TouchAction(driver).longPress(x,y).moveTo(x, y).release();
action.perform();发布于 2015-10-16 09:08:45
您可以尝试为所有移动设备使用这种安全的动态滑动代码:
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;
}https://stackoverflow.com/questions/33142406
复制相似问题