Appium getScreenshotAs () выбрасывает java .lang.IllegalStateException: невозможно сжать переработанное растровое изображение (Samsung Galaxy A3 2017) - PullRequest
0 голосов
/ 20 января 2020
public static BufferedImage createScreenshotOfMiddleOfTheElement(final MobileElement element) throws Exception {
    final File screenshotFile = element.getScreenshotAs(OutputType.FILE);
    final BufferedImage screenshot = ImageIO.read(screenshotFile);
    final int width = screenshot.getWidth() / 5;
    final int height = screenshot.getHeight() / 5;
    final int x = width * 2;
    final int y = height * 2;
    return screenshot.getSubimage(x, y, width, height);
}

В первой строке метода выше, при попытке сделать снимок экрана этого элемента, Appium выдаст:

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: java.lang.IllegalStateException: Can't compress a recycled bitmap
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'xyz-pc', ip: '10.100.0.244', os.name: 'Linux', os.arch: 'amd64', os.version: '5.3.7-arch1-1-ARCH', java.version: '1.8.0_222'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {appWaitPackage: x.y.z, automationName: UiAutomator2, databaseEnabled: false, desired: {appWaitPackage: x.y.z, automationName: UiAutomator2, deviceName: Android Device, platformName: android}, deviceApiLevel: 26, deviceManufacturer: samsung, deviceModel: SM-A320FL, deviceName: 5203e9e65af0c3a9, deviceScreenDensity: 320, deviceScreenSize: 720x1280, deviceUDID: 5203e9e65af0c3a9, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, pixelRatio: 2, platform: LINUX, platformName: Android, platformVersion: 8.0.0, statBarHeight: 48, takesScreenshot: true, viewportRect: {height: 1232, left: 0, top: 48, width: 720}, warnings: {}, webStorageEnabled: false}
Session ID: fd18b3e6-22af-4e34-945d-5797ddd00a6a

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)
at io.appium.java_client.DefaultGenericMobileElement.execute(DefaultGenericMobileElement.java:45)
at io.appium.java_client.MobileElement.execute(MobileElement.java:1)
at io.appium.java_client.android.AndroidElement.execute(AndroidElement.java:1)
at org.openqa.selenium.remote.RemoteWebElement.getScreenshotAs(RemoteWebElement.java:392)
at common.ImageUtils.createScreenshotOfMiddleOfTheElement(ImageUtils.java:19)

Код выполняется до этой точки правильно. Подозрительная вещь - она ​​ломается только на Samsung Galaxy A3 (2017). Как я могу это исправить?

...