Detox icon indicating copy to clipboard operation
Detox copied to clipboard

(WIP) Support multiple elements in getAttributes()

Open d4vidi opened this issue 3 years ago • 4 comments

Is your feature request related to a problem? Please describe.

As a follow-up action from #3180, we need to not only apply the type fixes for Android (i.e. for getAttributes()), but in fact introduce the functionality altogether.

Describe the solution you'd like getAttributes() should allow for returning an array of the attributes of all associated elements, given an ambiguous matcher.

d4vidi avatar Jan 30 '22 13:01 d4vidi

I have tested that the following works for iOS but not for Android: const multipleMatchedElements = await element(by.text('Multiple')).getAttributes(); (=clip from Detox documentation https://wix.github.io/Detox/docs/api/actions-on-element#getattributes. And Btw the documentation does not say this is iOS only...).

I have detox version 19.5.7.

Problem with Android is: "matches multiple views in the hierarchy".

So will #3196 solve this problem I have?

jaheikki avatar Apr 25 '22 09:04 jaheikki

@jaheikki That sounds exactly right. Keep track of this for resolution.

d4vidi avatar Apr 25 '22 15:04 d4vidi

Hi @d4vidi, what's the priority of this item? or any eta on this.. would be nice to see it implemented sooner rather than later

pradeipp avatar Aug 30 '22 08:08 pradeipp

It's very hard to provide ETA's on things that are not in our center-focus. Nevertheless, I estimate that within the upcoming weeks.

d4vidi avatar Aug 30 '22 13:08 d4vidi

This is a very important issue for some people, kindly look forward to this or at-least update the documentation accordingly since this only works for IOS not Android. I have wasted an entire day trying to fix this.

socialyadept avatar Nov 04 '22 15:11 socialyadept

Hoping this issue will be solved soon, I've been waiting for this since April. I have several Detox tests that are currently "iOS only" because of this issue. Thank you for your co-operation!

jaheikki avatar Dec 08 '22 09:12 jaheikki

Has there been any movement on this issue? I am hitting an issue on iOS where it gives the error

Property 'elements' does not exist on type 'IosElementAttributes | AndroidElementAttributes | { elements: IosElementAttributes[]; }'.
  Property 'elements' does not exist on type 'IosElementAttributes'.ts(2339)

when following the exact example laid out in the documentation

micahdasMA avatar Aug 02 '23 22:08 micahdasMA

Bump - also facing same issue as @micahdasMA:

  const attributes = await element(by.id('message')).getAttributes()
  jestExpect(attributes.text).toContain(message)

results in error:

Property 'text' does not exist on type 'IosElementAttributes | AndroidElementAttributes | { elements: IosElementAttributes[]; }'.
  Property 'text' does not exist on type '{ elements: IosElementAttributes[]; }'.ts(2339)

Detox version 20.11.3

eugenezhernakov avatar Aug 29 '23 09:08 eugenezhernakov

The issue is back on our table 🙏🏻 We will soon align typescript between platform (as much as possible) alongside the technical fix.

d4vidi avatar Sep 03 '23 14:09 d4vidi

This support was added in https://github.com/wix/Detox/pull/4184, which was released with version 20.12.0.

asafkorem avatar Sep 12 '23 21:09 asafkorem

@asafkorem I still get a ts error after updating to 20.12.0

Code const appElementAttributes = await element(by.id(appElement)).getAttributes(); jestExpect(appElementAttributes.elements.length).toBe(expectedCount);

Error Property 'elements' does not exist on type 'IosElementAttributes | AndroidElementAttributes | { elements: IosElementAttributes[]; } | { elements: AndroidElementAttributes[]; }'. Property 'elements' does not exist on type 'IosElementAttributes'.ts(2339)

micahdasMA avatar Sep 14 '23 19:09 micahdasMA