简体   繁体   中英

How to validate photo capture screen is open in Xamarin UITest?

I want to write unit test in Xamarin UITest to validate whether photo capture screen is open or not, for both Android and iOS. If anyone know this, can you please give me advice on that?

Thank you

You should write your test queries to navigate to the photo capture screen and call

app.Repl ();

Repl will pause the test and open up terminal window. There you can type any test queries you like.

If you type in tree in the terminal window, you will see view hierarchy of your current screen. And you should look for some elements that are unique to that screen.

For example I use UIImagePickerController to let users shoot an image in my iOS app. It has a button with the label Take Picture , so you could call standard

app.WaitForElement(c=>c.Marked("Take Picture"));

to wait for that button to appear. If it appears then photo capture screen is open. You can, of course, wait for any other element on that screen.

You can even do

app.Tap(c=>c.Marked("Take Picture"));

to tap that button and actually take a picture.

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