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.

UiAutomator locating with getChildByText runs into endless loop

See original GitHub issue

The problem

Searching with uiautomator strategy using getChildByText makes appium run into an endless loop.

Environment

  • Appium version (or git revision) that exhibits the issue: 1.6.5
  • Last Appium version that did not exhibit the issue (if applicable): -
  • Desktop OS/version used to run Appium: Mac OS Sierra
  • Node.js version (unless using Appium.app|exe): npm 4.2.0
  • Mobile platform/version under test: Android 7.0
  • Real device or emulator/simulator: real device Pixel C
  • Appium CLI or Appium.app|exe: CLI

Details

Link to Appium logs

Appium server log: https://gist.github.com/oscheller1/0ae20af66a3642521cde7ffa1ee25bdf

The last part of the log shows the endless loop, e.g.

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (9701)
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=9701, CONTAINER=UiSelector[SCROLLABLE=true], PATTERN=UiSelector[INSTANCE=2, PATTERN=UiSelector[CLASS=android.widget.RelativeLayout]]]

Code To Reproduce Issue [ Good To Have ]

Execute a search by uiautomator that searches inside a UiCollection for a UiObject that has a particular child which has set a particular text. E.g.

new UiScrollable(new UiSelector().scrollable(true)).getChildByText(new UiSelector().className("android.widget.RelativeLayout"), "Backofen")

P.s.

On that note,

see documentation for getChildByText: https://developer.android.com/reference/android/support/test/uiautomator/UiCollection.html#getChildByText(android.support.test.uiautomator.UiSelector, java.lang.String)

Then see appium documentation: https://appium.readthedocs.io/en/stable/en/writing-running-appium/uiautomator_uiselector/ that says:

Find the first scrollable element, then find a TextView with the text "Tabs". The "Tabs" element will be scrolled into view.

# ruby
element = find_element(:uiautomator, 'new UiScrollable(new UiSelector().scrollable(true).instance(0)).getChildByText(new UiSelector().className("android.widget.TextView"), "Tabs")')

which does not match the explained functionality of getChildByText on the android docs. Should it work like the android docs say, or does it work as described in the appium docs?

From my understanding, the query from above (under ‘Code To Reproduce Issue’) should find a relative layout that has some child (or even descendant) element with a text property of Backofen. The relative layout should be inside a scrollable container. Appium should return the relative layout as a webdriver element, and NOT the text element.

There are multiple relative layouts in that container, and the query shall find the one that includes that particular text as a child (or descendant) element.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jlippscommented, Sep 14, 2017

closing for now since I can’t think of anything to try and fix in appium

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

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

UIScrollable getChildByText doesnt scroll enough before it ...
When I run this on a KitKat phone, phone goes to home screen, then clicks "Apps" then selects "Apps tab" (this part of...
Read more >
Android Developer Fundamentals Course – Concepts
Libraries and Android Runtime: Each app runs in its own process and with ... If your computer still does not find the device...
Read more >
Write automated tests with UI Automator - Android Developers
The UI Automator testing framework provides a UiDevice class to access and perform operations on the device on which the target app is...
Read more >
UiSelector Guide - Appium
Edit this Doc uiautomator UiSelector ... Find the first scrollable element, then find a TextView with the text "Tabs". ... getChildByText(new UiSelector().
Read more >
Android testing: UI Automator (Part 4)
After these changes you can find updated run menu and run your tests or an application. Run tests in Android Studio. Use gradle....
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