Search code examples
c#androidxamarin.androidxamarin.uitestuitest

XamarinUITest How to get text from alert pop up in android App


Our application is built on xamarin form and I am performing xamarin UITest to automate the android native app.

Problem: During the validation I have to get the text from pop up box to compare with expected text

My approach: Using app.repl() I have identified the AppQuery of buttons in pop up and able to perform action on them(PFB Screenshot). But i am not ale to get the text of pop up message. Tried to use uiautomator to get identify the pop up elements but couldn't identify the xpath

Expected Output: Please confirm that the following S-Number is correct: S855555

can someone please guide me on how to get the pop up text and validate in xamarin uitest.

enter image description here

enter image description here


Solution

  • In my case, below query is able to return the text from the screenshot

    app.Query(x => x.Id("scrollView").Descendant().Id("message").Id("message").Invoke("getText"))[0];

    https://i.sstatic.net/s9so3.png