You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are testing our app with appium, we can set a accessiblityLabel for any element and use it in our test script. However, I found that even if I set it for this custom toast component, it's not able to be located.
Any idea? I'd just like to verify the toast message in my test script.
Test script:
it('should display error message given wrong credentials',async()=>{await$('~username').setValue('hello');await$('~password').setValue('world');await$('~btnLogin').click();// https://stackoverflow.com/questions/30458931/how-to-test-android-toast-messages-in-appium-selenium-java// const message = await $('//android.widget.Toast[1]').getText();constmessage=await$('~toastMessage').getText();expect(message).toBe('Wrong ID or Password');});
Update: I managed to identify the text on toast message with appium OCR plugin, but it's a little overkill
// only if we can find the toast element by its accessibilityLabel like we do for username and password// const message = await $('~toastMessage').getText();// expect(message).toBe('Wrong ID or Password');// workaround: use ocr to take a screenshot and recognize the textawaitdriver.ocrWaitForTextDisplayed('Wrong ID or Password',{androidRectangles: {top: 1012,left: 259,right: 834,bottom: 1164,},timeout: 5000,});
Avoid position=”absolute” for container's views
There is a problem that appium doesn’t see elements inside absolutely positioned views. So you can’t interact with. [Learn more](http://www.wswebcreation.nl/clicking-on-an-element-with-appium-that-cant-be-found-in-the-ui-tree/).
Also using ocr is not that bad for our app, so feel free to close this issue.
Hello, dear component author,
We are testing our app with appium, we can set a accessiblityLabel for any element and use it in our test script. However, I found that even if I set it for this custom toast component, it's not able to be located.
Any idea? I'd just like to verify the toast message in my test script.
Test script:
Component code:
The text was updated successfully, but these errors were encountered: