Appium_Android_Java_Cannot用ashot拍照

时间:2018-06-08 08:27:05

标签: java android appium ashot

我试图用ashot拍摄截图(只关注一个元素),但我得到了一个错误: java.lang.RuntimeException:org.openqa.selenium.WebDriverException:Method is未实现(警告:服务器未提供任何堆栈跟踪信息)

这是依赖关系的信息:

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.4.0</version>
    </dependency>

    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>5.0.0-BETA6</version>
    </dependency>

    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.14.3</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>ru.yandex.qatools.ashot</groupId>
        <artifactId>ashot</artifactId>
        <version>1.5.4</version>
    </dependency>

    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-core</artifactId>
        <version>1.3</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.7</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.9</version>
    </dependency>

    <dependency>
        <groupId>com.aventstack</groupId>
        <artifactId>extentreports</artifactId>
        <version>3.1.5</version>
        <scope>provided</scope>
    </dependency>`

这是捕获截图功能

public void capture(String folder, String screenShotName, MobileElement 
mobileElement) throws Exception
    {

        Screenshot screenshot = new AShot().takeScreenshot(driver, mobileElement);
        BufferedImage actualImage = screenshot.getImage();
        String dest = ApplicationConfig.CAPTUREDSCREEN_DIR +
 "\\" + folder + "\\" + screenShotName+  ".png";
        ImageIO.write(actualImage,"PNG",new File(dest));
    }

请帮帮我。

感谢!!!!

1 个答案:

答案 0 :(得分:0)

  

WebDriver截图实用程序

     

在不同平台上拍摄 WebElement 的屏幕截图(即   桌面浏览器,iOS模拟器移动Safari,Android模拟器   浏览器)装饰屏幕截图提供灵活的屏幕截图比较

来源:https://github.com/yandex-qatools/ashot

我认为他们不支持MobileElement

的截屏截图