VisualReview-protractor
VisualReview-protractor copied to clipboard
Failure on Android
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.