简体   繁体   中英

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

You could try the code below:

app.Query(c=>c.Marked("Confirm").Parent().Class("AlertDialogLayout"))

For more details, you could refer to the link below. https://social.msdn.microsoft.com/Forums/en-US/ad1079f7-0406-4709-86ae-7945f93b79e5/handling-popups-with-xamarinuitest?forum=xamarintestcloud

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.stack.imgur.com/s9so3.png

app.Query(e => e.Id("message"))[0].Text

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM