之前用Python试验过的,相同的测试方法使用Java试验一遍,记录记录。
1.酷狗“听”页面拖动“乐库”和“歌单”换位置,动作前后截图
2.打开相机,浏览并放大图片
运行环境 Java1.8 ; Java-client-4.1.2 ; selemium3.0 ; Appium-linux-1.12.1.AppImage
Java中driver.pinch(WebElement l), driver.zoom(WebElement l)可以调用,但是实际使用没实现放大缩小照片的效果。
参考:https://www.cnblogs.com/longronglang/p/10318109.html
https://www.cnblogs.com/ali-test/p/11221594.html
关于模拟双指拖动放大图片,没按人家的等待时间来,试验时设置模拟点击后等待0.25秒就开始移动,结果只能从移动轨迹上看出确实往两侧拖动了,但就是没放大的效果,明明类似的方法,Python设置250ms后移动就行的,Java这折腾了半天,改成跟人家一模一样的等待2000ms,成功了!( ⊙ o ⊙ )
截图方法关键也是一句 webdriver.getScreenshotAs(OutputType.FILE),File形式,后面需要copy出去。
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui