I am waiting for an element to be displayed which is a textView in Android.
let textUnderName = await driver.$('android=new UiSelector().resourceId("com.example.app.stage.hockey:id/shortMessage")');
await textUnderName.waitForDisplayed(10000);
//until here everything is fine, it is waiting for it to be shown but here
let fetchTheText = textUnderName.text() //here the error "text() is not a function" is thrown
I have also tried this after the element was shown:
let fetchTheText = await driver.$('android=new UiSelector().resourceId("com.example.app.stage.hockey:id/shortMessage")').text();
I am using:
[email protected]
[email protected]
with JavaScript
I can see from the logs that the element is being found properly, but I cannot read the text that is written on this textView (textField). I tried both text() and getText() methods, for both of them I get an erorr saying that they are not functions.
How can I fix this issue? How can I be able to get the text and store it the text in a variable because I want to do an assertion and decide if the test passes (fails) based on this text ?!