几天前我开始学习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);
答案 0 :(得分:0)
您可以尝试使用TouchAction类执行滑动。
TouchAction action = new TouchAction(driver).longPress(x,y).moveTo(x, y).release();
action.perform();
答案 1 :(得分:0)
您可以尝试使用这种代码安静的方式对所有移动设备进行动态刷卡:
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;
}