Answer the question
In order to leave comments, you need to log in
How to get text from Text element in Appium for React Native?
In the element component:
<Text {...setTestId('textTest')}>мне нужен этот текст</Text>
const firstHtmlView = await client.$('~textTest');
const text = await firstHtmlView.getText();
console.log('text', text);
text textTest
Answer the question
In order to leave comments, you need to log in
Wasted almost a day on this issue. As usual, everything turned out to be banal:
the problem was in the setTestId function. As everyone probably knows, there is a problem with finding elements by testId on Android. And therefore it is searched for by accessibilityLabel.
Here is the function for the test environment, it returned such an object for me:
I installed both. I do not mind. And it turned out it was necessary to put only one desired value. Like this:
return Platform.OS === 'android'
? { accessible: true, accessibilityLabel: id }
: { testID: id };
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question