How to handle dynamically element in Android Native app using Appium(Java)


I have scenario to handle dynamically changing element.

I have a message saying "Sure. Picking your name as TestUser1"
In the above message italic text changes every time.
for ex:
Sure. Picking your name as TestUser1
Got it. Picking your name as TestUser1
Understood. Picking your name as TestUser1.

My question is how to validate the above message based on TestUser1.

Thanks in advance.

you can get element by text/partial_text like:

String text = "Picking your name as TestUser1";
WebElement el = driver.findElement(MobileBy.AndroidUIAutomator("new UiSelector().textContains(\"" + text + "\")"))

@Aleksei Thanks… It worked…

You can also watch this video :