Selenium实现Web UI自动化截图长图

首先加入dependency

ru.yandex.qatools.ashot

ashot

1.5.4

代码如下

public void longScreenShot(String screenShotFileName) {

Screenshot screenshot =

new AShot()

.shootingStrategy(ShootingStrategies.viewportPasting(1000))

.takeScreenshot(driver);

try {

ImageIO.write(screenshot.getImage(),"PNG",new File(TARGET_SCREENSHOTS_PATH + screenShotFileName + ".png"));

logger.info("Long screenshot obtained successfully :long screen Shot file Name is {}",screenShotFileName);

} catch (IOException e) {

logger.error("Long screenshot obtained fail");

e.printStackTrace();

}

}

你可能感兴趣的:(自动化测试,Java,java,前端,服务器)