question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Certain Emulators Are Getting Device Size Returns 0 for both Length and Height

See original GitHub issue

The 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:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
mykola-mokhnachcommented, Apr 25, 2019

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.

0reactions
lock[bot]commented, Apr 25, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get screen width and height in Android - Stack Overflow
Using this code, you can get the runtime display's width & height: DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().
Read more >
Create and manage virtual devices - Android Developers
Learn how to create and manage virtual devices in Android Studio. ... Android TV, or Automotive OS device that you want to simulate...
Read more >
First, Understand Your Screen - Tripleodeon
height </a>. These two properties are generally understood to return the physical dimensions of the screen upon which a browser is running. On ......
Read more >
Camera - Expo Documentation
Returns a Promise that resolves to an array of strings representing picture sizes that can be passed to pictureSize prop. The list varies...
Read more >
Build Android UIs for any screen size - YouTube
Large Screens represent an important and the fastest growing segment of active Android devices, so now is the time to make your UI...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found