Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Failure on Android #21

Open
monkpit opened this issue May 11, 2018 · 0 comments
Open

Failure on Android #21

monkpit opened this issue May 11, 2018 · 0 comments

Comments

@monkpit
Copy link

monkpit commented May 11, 2018

When I try to use this plugin and test on a real Android device, I get the following error message:

Failed: unknown error: operation is unsupported on Android

The root cause is in _getProperties(), the call to browser.manage().window().getSize() is not supported on Android.

My workaround is the following:

function _getProperties(browser) {
  return browser.getCapabilities()
    .then(_propertiesFn)
    .then(function (properties) {
      return browser.manage().window().getSize().then(function (size) {
        properties.resolution = size.width + 'x' + size.height;
        return properties;
      }).catch(() => {
        return browser.executeScript("return (window.innerWidth || document.body.clientWidth) + 'x' + (window.innerHeight || document.body.clientHeight)")
          .then(function (resolution) {
            properties.resolution = resolution;
            return properties;
          });
      });
    });
}

The only issue here is that the resolution is not always consistent. For example, I have seen my Galaxy S6 report most screenshots as 360x560 when running Chrome, however some pages report 368x573.

Another option would be: instead of returning a size, just return the string 'device' or 'default' instead of trying to grab a resolution.

Yet another option would be to rearrange the logic to grab the resolution from the screenshot PNG itself.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant