Screen shot issue in selenium webdriver

前端 未结 3 837
执念已碎
执念已碎 2020-12-22 04:06

I have a screen shot issue. When I am capturing a screen, it takes only the Visible screen. I want to capture the entire page. Here below is my code.

WebDriv         


        
3条回答
  •  青春惊慌失措
    2020-12-22 04:28

    If you use maven then you may use AShot to accomplish your task. For this you need to add dependency in your pom file:

    
        ru.yandex.qatools.ashot
        ashot
        1.5.2
    
    

    And use the code snippet as follows:

    Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(augmentedDriver);
    ImageIO.write(screenshot.getImage(), "PNG", new File("d:\\tmp\\results.png"));
    

    But, if you aren't using maven then download ashot jar (version: 1.5.2) file and add it to your build path. Here's the link your help: https://javalibs.com/artifact/ru.yandex.qatools.ashot/ashot

    Hope, that might help you.

提交回复
热议问题