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.

Inconsistent behavior of getting text from an element

See original GitHub issue

The problem

I’ve found there are some inconsistent behavior related to an element including new lines.

  • Some locator with new lines succeeds, but others fail.
  • Even the same element returns different texts when found by a different locator.

Environment

  • Appium version (or git revision) that exhibits the issue: 1.21.0
  • Last Appium version that did not exhibit the issue (if applicable): -
  • Desktop OS/version used to run Appium: macOS 10.15 Catalina
  • Node.js version (unless using Appium.app|exe): 12.13.1
  • Npm or Yarn package manager: npm 6.12.1
  • Mobile platform/version under test: iOS 14 / Android 10.0
  • Real device or emulator/simulator: iOS simulator / iOS real device / Android emulator
  • Appium CLI or Appium.app|exe: Appium CLI

Details

Suppose we have a dialog whose message contains a new line like this (This is iOS case) line-break-dialog

We expect that we can use same text in locators to find the element, but actually the required locator is different between -ios class chain and xpath. New lines in xpath is replaced with a space. But it’s not the case on Android. Besides, even the returned text is different. The second phenomenon looks especially strange for me.

Is it an intentional result? We’d like to know what is the expected behavior.

Platform Locator strategy Find element result Get text result
iOS -ios class chain Succeeds only when the locator contains a new line Contains a new line
iOS xpath Succeeds only when the new line is replaced with a space Doesn’t contain a new line
Android xpath Succeeds only when the locator contains a new line Contains a new line

Link to Appium logs

Code To Reproduce Issue [ Good To Have ]

I’m sorry it’s difficult to provide it immediately because the code is tightly connected with our own system. If detail investigation using actual code is required, please let me know.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
jlippscommented, Oct 19, 2021

I think at this stage it’s safer to leave minor inconsistencies between XPath across platforms. It’s not as if XPath queries generally work cross-platform anyway (since each platform has its own unique set of class names). The way Android and iOS render element text to the accessibility systems is also in no way guaranteed to be the same.

0reactions
nkns165commented, Oct 20, 2021

Thank you for your quick responses! Then we will develop based on the current behavior.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Recognize Gaps & Inconsistencies in a Text - Study.com
Gaps and inconsistences can make a text unclear and confusing for an audience. Learn how to recognize dangerous gaps and inconsistencies ...
Read more >
Inconsistent behaviour for HTML patterns - Stack Overflow
I'm trying to get HTML patterns to work. The behaviour I expect is that as soon as text that doesn't match a given...
Read more >
Selenium - Input Text - Inconsistent failures
The problem is that the Input_Text keyword would SOMETIME not enter the text into the textbox. A test would run fine in 1...
Read more >
Inconsistent behaviour of Click() in Selenium
It is better to use ids than XPath because XPath changes as elements are moved around the page, making your tests more fragile....
Read more >
The poor, misunderstood innerText - Perfection Kills
That quirky, non-standard way of element's text retrieval, ... (also being curiously inconsistent with their "opacity: 0" behavior).
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