Detox
Detox copied to clipboard
(WIP) Support multiple elements in getAttributes()
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.
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 That sounds exactly right. Keep track of this for resolution.
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
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.
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.
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!
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
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
The issue is back on our table 🙏🏻 We will soon align typescript between platform (as much as possible) alongside the technical fix.
This support was added in https://github.com/wix/Detox/pull/4184, which was released with version 20.12.0.
@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)