• <bdo id='OKoiz'></bdo><ul id='OKoiz'></ul>
        <legend id='OKoiz'><style id='OKoiz'><dir id='OKoiz'><q id='OKoiz'></q></dir></style></legend>

        <small id='OKoiz'></small><noframes id='OKoiz'>

        <i id='OKoiz'><tr id='OKoiz'><dt id='OKoiz'><q id='OKoiz'><span id='OKoiz'><b id='OKoiz'><form id='OKoiz'><ins id='OKoiz'></ins><ul id='OKoiz'></ul><sub id='OKoiz'></sub></form><legend id='OKoiz'></legend><bdo id='OKoiz'><pre id='OKoiz'><center id='OKoiz'></center></pre></bdo></b><th id='OKoiz'></th></span></q></dt></tr></i><div id='OKoiz'><tfoot id='OKoiz'></tfoot><dl id='OKoiz'><fieldset id='OKoiz'></fieldset></dl></div>
      1. <tfoot id='OKoiz'></tfoot>
      2. 如何通过 Selenium 和 Java 使用 AShot 库截取整页截图

        How to take full page screenshot using AShot library through Selenium and Java(如何通过 Selenium 和 Java 使用 AShot 库截取整页截图)
        <tfoot id='1lGGU'></tfoot>

          <bdo id='1lGGU'></bdo><ul id='1lGGU'></ul>

            <small id='1lGGU'></small><noframes id='1lGGU'>

              <tbody id='1lGGU'></tbody>
            1. <i id='1lGGU'><tr id='1lGGU'><dt id='1lGGU'><q id='1lGGU'><span id='1lGGU'><b id='1lGGU'><form id='1lGGU'><ins id='1lGGU'></ins><ul id='1lGGU'></ul><sub id='1lGGU'></sub></form><legend id='1lGGU'></legend><bdo id='1lGGU'><pre id='1lGGU'><center id='1lGGU'></center></pre></bdo></b><th id='1lGGU'></th></span></q></dt></tr></i><div id='1lGGU'><tfoot id='1lGGU'></tfoot><dl id='1lGGU'><fieldset id='1lGGU'></fieldset></dl></div>

              • <legend id='1lGGU'><style id='1lGGU'><dir id='1lGGU'><q id='1lGGU'></q></dir></style></legend>
                • 本文介绍了如何通过 Selenium 和 Java 使用 AShot 库截取整页截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我尝试了下面的代码来截取整页截图.但只捕获可见区域,

                  I tried the below code for taking full page screenshot. But only the visible area is captured,

                  public void Fullscreen (WebDriver driver) 
                  {
                      try {
                          final Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver);
                          final BufferedImage image = screenshot.getImage();
                          ImageIO.write(image, "PNG", new File("D:\" + "AShot_BBC_Entire.png"));           
                      } catch(Exception e){
                          System.out.println(e.getMessage());
                      }
                  }
                  

                  推荐答案

                  在使用 Selenium Java Client v3.14.0ChromeDriver v2.41Chrome 时v 68.0 使用 ashot-1.4.4.jar 这是一个使用 ChromeDriver 水平和垂直截取 完整页面截图 的示例> 和 url https://jquery.com/aShot 库:

                  While working with Selenium Java Client v3.14.0, ChromeDriver v2.41, Chrome v 68.0 using ashot-1.4.4.jar here is an example to take the complete page screenshot both horizontally and vertically using ChromeDriver and aShot Library of the url https://jquery.com/:

                  • 代码块:

                  • Code Block:

                  import java.io.File;
                  import javax.imageio.ImageIO;
                  import org.openqa.selenium.WebDriver;
                  import org.openqa.selenium.chrome.ChromeDriver;
                  import org.openqa.selenium.chrome.ChromeOptions;
                  import org.openqa.selenium.support.ui.ExpectedConditions;
                  import org.openqa.selenium.support.ui.WebDriverWait;
                  
                  import ru.yandex.qatools.ashot.AShot;
                  import ru.yandex.qatools.ashot.Screenshot;
                  import ru.yandex.qatools.ashot.shooting.ShootingStrategies;
                  
                  public class ashot_CompletePage {
                  
                      public static void main(String[] args) throws Exception {
                  
                          System.setProperty("god.bless.you", "C:\Utility\BrowserDrivers\chromedriver.exe");
                          ChromeOptions options = new ChromeOptions();
                          options.addArguments("start-maximized");
                          options.addArguments("disable-infobars");
                          options.addArguments("--disable-extensions"); 
                          WebDriver driver =  new ChromeDriver(options);
                          driver.get("https://jquery.com/");
                          new WebDriverWait(driver, 20).until(ExpectedConditions.titleContains("jQuery"));
                          Screenshot myScreenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(100)).takeScreenshot(driver);
                          ImageIO.write(myScreenshot.getImage(),"PNG",new File("./Screenshots/elementScreenshot.png"));
                          driver.quit();
                      }
                  }
                  

                • 截图:

                • Screenshots:

                  您可以在 如何截取屏幕截图中找到详细讨论使用 Selenium WebDriver

                  这篇关于如何通过 Selenium 和 Java 使用 AShot 库截取整页截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!
                • 相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                    1. <legend id='dzGPK'><style id='dzGPK'><dir id='dzGPK'><q id='dzGPK'></q></dir></style></legend>

                          <tbody id='dzGPK'></tbody>

                        <small id='dzGPK'></small><noframes id='dzGPK'>

                        <i id='dzGPK'><tr id='dzGPK'><dt id='dzGPK'><q id='dzGPK'><span id='dzGPK'><b id='dzGPK'><form id='dzGPK'><ins id='dzGPK'></ins><ul id='dzGPK'></ul><sub id='dzGPK'></sub></form><legend id='dzGPK'></legend><bdo id='dzGPK'><pre id='dzGPK'><center id='dzGPK'></center></pre></bdo></b><th id='dzGPK'></th></span></q></dt></tr></i><div id='dzGPK'><tfoot id='dzGPK'></tfoot><dl id='dzGPK'><fieldset id='dzGPK'></fieldset></dl></div>
                        • <bdo id='dzGPK'></bdo><ul id='dzGPK'></ul>
                            <tfoot id='dzGPK'></tfoot>