Hi,
I would like to find out how to work with pop-ups and Xamarin.UITest, for example:
I've seen a couple of posts about this topics but no answers yet.
Thanks,
Chris
This should help you get started...
Query for the Alert Control
iOS :: app.Query(c=>c.ClassFull("_UIAlertControllerView"))
Android :: app.Query(c => c.Class("AlertDialogLayout"))
Query for the OK
button on the Alert Control
iOS :: app.Query(c=>c.Marked("OK").Parent().ClassFull("_UIAlertControllerView"))
Android :: app.Query(c=>c.Marked("OK").Parent().Class("AlertDialogLayout"))
Code Sample - https://gist.github.com/mattregul/993b7e3e719a9b636b6cc74c5dce2253#file-displayalertuitest-cs-L32
Additional Resources:
1. Working with Repl - https://developer.xamarin.com/guides/testcloud/uitest/working-with/repl/
2. Test Recorder - https://www.xamarin.com/test-cloud/recorder
3. (more) Test Recorder - https://developer.xamarin.com/guides/testcloud/testrecorder/
4. Query Child Walk-up - https://forums.xamarin.com/discussion/27242/app-query-syntax-documentation-e-g-get-the-immediate-parent-of-an-element
iOS Tree
[CalabashRootView > UIWindow]
[UIView > ... > Xamarin_Forms_Platform_iOS_LabelRenderer]
[UILabel] label: "Welcome to Xamarin Forms!", text: "Welcome to Xamarin Forms!"
[UITransitionView]
[UIView]
[UIView]
[_UIAlertControllerView > ... > _UIAlertControllerInterfaceActionGroupView] label: "Title"
[_UIDimmingKnockoutBackdropView]
[UIView]
[UIVisualEffectView]
[_UIVisualEffectBackdropView]
[_UIVisualEffectFilterView]
[UIView]
[_UIInterfaceActionGroupHeaderScrollView > UIView]
[UILabel] label: "Title", text: "Title"
[UILabel] label: "Message", text: "Message"
[UIView]
[UIView]
[_UIInterfaceActionItemSeparatorView_iOS > UIView]
[_UIInterfaceActionRepresentationsSequenceView > ... > _UIInterfaceActionCustomViewRepresentationView]
[_UIAlertControllerActionView > UIView] label: "OK"
[UILabel] label: "OK", text: "OK"
Android Tree
[[object CalabashRootView]]
[PhoneWindow$DecorView > ... > FrameLayout]
[FitWindowsFrameLayout] id: "action_bar_root"
[ContentFrameLayout] id: "content"
[AlertDialogLayout] id: "parentPanel"
[LinearLayout] id: "topPanel"
[LinearLayout] id: "title_template"
[DialogTitle] id: "alertTitle" text: "Title"
[Space] id: "titleDividerNoCustom"
[FrameLayout] id: "contentPanel"
[NestedScrollView > LinearLayout] id: "scrollView"
[AppCompatTextView] id: "message" text: "Message"
[ScrollView > ButtonBarLayout] id: "buttonPanel"
[AppCompatButton] id: "button2" text: "OK"
[PhoneWindow$DecorView]
[LinearLayout > FrameLayout]
[FitWindowsFrameLayout] id: "action_bar_root"
[ContentFrameLayout > RelativeLayout] id: "content"
[View]
[PlatformRenderer]
[NavigationPageRenderer] id: "NoResourceEntry-1"
[PageContainer > ... > LabelRenderer]
[FormsTextView] text: "Welcome to Xamarin Forms!"
[Toolbar] id: "toolbar"
[AppCompatTextView] text: "DisplayAlertUITest"
[View] id: "navigationBarBackground"
Answers
@Chris.3704,
Could you post a screenshot of a "pop-up"? I am not sure which type of UI you are referring to.
Hi John,
sure, so I'm creating them in Xamarin.Forms, e.g.
App.Current.MainPage.DisplayAlert(@Create Form Error, DownloadWarning, "OK");
So on the native layer they boil down to:
Android:
AlertDialog.Builder
iOS:
UIAlertView
This should help you get started...
Query for the Alert Control
iOS ::
app.Query(c=>c.ClassFull("_UIAlertControllerView"))
Android ::
app.Query(c => c.Class("AlertDialogLayout"))
Query for the
OK
button on the Alert ControliOS ::
app.Query(c=>c.Marked("OK").Parent().ClassFull("_UIAlertControllerView"))
Android ::
app.Query(c=>c.Marked("OK").Parent().Class("AlertDialogLayout"))
Code Sample - https://gist.github.com/mattregul/993b7e3e719a9b636b6cc74c5dce2253#file-displayalertuitest-cs-L32
Additional Resources:
1. Working with Repl - https://developer.xamarin.com/guides/testcloud/uitest/working-with/repl/
2. Test Recorder - https://www.xamarin.com/test-cloud/recorder
3. (more) Test Recorder - https://developer.xamarin.com/guides/testcloud/testrecorder/
4. Query Child Walk-up - https://forums.xamarin.com/discussion/27242/app-query-syntax-documentation-e-g-get-the-immediate-parent-of-an-element
iOS Tree
Android Tree
Awesome! Thanks so much, Matthew.
Nice Solution, But I need to get message texts, For example in my case Popup contains "successful" word in one of the message, now i want to print message texts only when perticular message get displayed. at that time how to compare particular word? is there anything similar to '%Like%' ??