0

I am testing pressing OK on SYSTEM_ALERT_WINDOW on Android using Xamarin testcloud.

However, I get below error. Has anyone tried testing on alert window? Does Xamarin test cloud work on normal android activities or alert windows as well?

Exception: System.Exception: Unable to find element. Query for Button("btnOK") gave no results.

I am using the usual query, and button is defined properly.

Func<AppQuery, AppQuery> MyButton = c => c.Button("btnOK");

<ImageButton
    android:id="@+id/btnOK"
.. 
</>

PS: I can see that alert window is shows up correctly in screenshot when test was marked failed.

Henry
  • 81
  • 6

1 Answers1

0

You should use the Marked instead of Button method because it matches common values like the id on Android, see also here.

Thus, this should work:

Func< AppQuery, AppQuery> MyButton = c => c.Marked("btnOK");
vagrawal
  • 1
  • 2
  • Why should the original poster try this? Please explain you solution. – Martin Zabel Jan 14 '16 at 21:20
  • Not sure why "< AppQuery, AppQuery >" was not visible at first, if thats what ur concern was. but using "Marked" instead of c.Button was main thing.. Let me know if you still needs explanation – vagrawal Jan 14 '16 at 22:09
  • At first, please format code as code in the edit view, see help there. Then explain, why you replaced `Button` by `Marked`. – Martin Zabel Jan 14 '16 at 22:14
  • Because marked has always worked for me on both platform :-http://developer.xamarin.com/api/member/Xamarin.UITest.Queries.AppQuery.Marked/p/System.String/ – vagrawal Jan 14 '16 at 22:19
  • I have made an edit to your answer, to show you what should be at least included in an answer. Accept it if you like it. I see now, that it must read `method` instead of `message`, please fix it afterwards. I can't do this until my edit is accepted. – Martin Zabel Jan 14 '16 at 22:26
  • Also, according to this :- http://developer.xamarin.com/api/member/Xamarin.UITest.Queries.AppQuery.Button/p/System.String/ for "Button" to work - "For Android: An element that has class (or inherits from) android.widget.Button" but ImageButton does not inherit from android.widget.Button.. Hope it helps. – vagrawal Jan 14 '16 at 22:28
  • If this is a relevant detail, then include it in your answer instead of just posting it as a comment. Also change the word "message" to "method" in the answer. – Martin Zabel Jan 15 '16 at 11:54