Certain Emulators Are Getting Device Size Returns 0 for both Length and Height
See original GitHub issueThe problem
I’m seeing an issue where emulators return Height and Width return 0 when getting device size.
Environment
- Appium version (or git revision) that exhibits the issue: 1.13.0-beta.3
- AutomationName: Uiautomator2
- Last Appium version that did not exhibit the issue (if applicable): 1.11.1
- Node.js version (unless using Appium.app|exe): 6.4.1
- Real device or emulator/simulator: Android Emulator (Google Nexus and Google Pixel)
Details
I’m noticing an issue with certain emulators where getting the device’s size, height and width returns 0. As a result, TouchAction Swipes are performed, but don’t move either up or down the screen. The context is also set to Webview when getting Device’s size was performed. Getting size of MobileElements on the screen does return a value of height and width.
Other emulator models, such as Samsung Galaxy are able to get device size and Element size without issue and can perform Touch Action swipes.
Let me know if you need more info.
Link to Appium logs
Link for Google Nexus Emulator returns device size as zero: https://gist.github.com/InvisibleExo/88d7ba06b5d9a542ee8f423821b22fe3
Code To Reproduce Issue [ Good To Have ]
Please remember that with sample code it’s easier to reproduce the bug and it’s much faster to fix it.
void swipeThroughElementVertical(double startPercentage, double endPercentage, int duration,
MobileElement element) {
size = element.getSize();
int width = (int) (size.width/2);
int startPoint = (int) (size.getHeight() * startPercentage);
int endPoint = (int) (size.getHeight() * endPercentage);
new AndroidTouchAction(driver)
.press(PointOption.point(width, startPoint))
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(duration)))
.moveTo(PointOption.point(width, endPoint))
.release()
.perform();
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top GitHub Comments
As far as I can see such response is coming from chromedriver and has nothing to do with the native context. You can try to report an issue to them or just remember the screen size taken from the native context or session capabilities as a workaround.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.