Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用java selenium webdriver ashot firefox自动拍摄包含固定元素的网页全屏快照_Java_Maven_Selenium_Automated Tests_Ashot - Fatal编程技术网

如何使用java selenium webdriver ashot firefox自动拍摄包含固定元素的网页全屏快照

如何使用java selenium webdriver ashot firefox自动拍摄包含固定元素的网页全屏快照,java,maven,selenium,automated-tests,ashot,Java,Maven,Selenium,Automated Tests,Ashot,我正在使用JavaSelenium和ashot的组合来拍摄网页的全屏快照 环境: Firefox Quantum 66.0b10(64位) geckodriver-v0.24.0-win64 jdk-8u201-windows-x64 apache-maven-3.6.0-bin IntellJ IDEA 2018.3.4 <dependency> <groupId>junit</groupId> <artifac

我正在使用JavaSelenium和ashot的组合来拍摄网页的全屏快照

环境:
  • Firefox Quantum 66.0b10(64位)

  • geckodriver-v0.24.0-win64

  • jdk-8u201-windows-x64

  • apache-maven-3.6.0-bin

  • IntellJ IDEA 2018.3.4

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>
    
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-firefox-driver</artifactId>
            <version>3.141.59</version>
        </dependency>
    
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>htmlunit-driver</artifactId>
            <version>2.33.2</version>
        </dependency>
    
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>3.141.59</version>
        </dependency>
    
        <dependency>
            <groupId>ru.yandex.qatools.ashot</groupId>
            <artifactId>ashot</artifactId>
            <version>1.5.2</version>
        </dependency>
    
    }

    预期结果: 请看这些图片

    您可以使用
    WebElement
    拍摄整个页面的屏幕截图

    WebElement body = driver.findElement(By.tagName("body"));
    File scrFile = ((TakesScreenshot)body).getScreenshotAs(OutputType.FILE);
    FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));
    
    WebElement body = driver.findElement(By.tagName("body"));
    File scrFile = ((TakesScreenshot)body).getScreenshotAs(OutputType.FILE);
    FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));