4

I'm using the Xamarin.UITest framework to assert if some button is disabled or enabled. Unfortunately it seems that this is not working if the "Enabled" Property of the button is set via binding trough MVX (binding is working - button is really disabled).

Example axml with two buttons:

    <xxx.Widgets.Button
        android:id="@+id/btnSave"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:text="Save"
        style="@style/DefaultButton"
        local:MvxBind="Click SaveAndContinueCommand; Enabled SaveButtonActive" />
    <xxx.Widgets.Button
        android:id="@+id/btnTest"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:text="Test"
        style="@style/DefaultButton"
        android:enabled="false" />

Query with Xamarin.UITest:

var button = App.Query(v => v.Button("Save")).FirstOrDefault();
Assert.IsFalse(button.Enabled); // -> Button is always enabled

var testButton = App.Query(v => v.Button("Test")).FirstOrDefault();
Assert.IsFalse(button.Enabled); // -> Button is disabled. Correct!

Do I need to pay attention on something different? Has anyone experience with the combination of MVX and Xamarin.UITest?

Michael Probst
  • 111
  • 2
  • 8

1 Answers1

0

I don't typically check button properties at the UI test level. I would check that in the core tests where I know that works. With that being said, you could actually tap the button with the UI test and verify that nothing happens if that's possible.

The next thing I would try is fire up your app with Calabash enabled, navigate to this screen and query the buttons to verify you are checking the properties that you should be.

PkL728
  • 955
  • 8
  • 21
  • Jap I could check the screen after tapping the button. But Xamarin exposes properties like "isEnabled" for view elements - and apparently this is not working for bound properties (I need to check it with bounded text prop as well). The provided REPL shell only knows the "tree" command which returns all view elements on the screen but without their properties. Querying all elements via c# code returns the state I mentioned - isEnabled Prop is wrong. Is there a way to directly read specific properties by casting (?) the AppQuery Result to an Android Button or maybe with build-in methods? – Michael Probst Mar 16 '15 at 08:06
  • What happens if you programmatically change the IsEnabled property of the button to true after it shows up on the screen as false? I'm curious if it still returns false in Xamarin UI test for that property... I have a hard time believing this is a MvvmCross data binding issue and think this is just an issue where perhaps Xamarin UI test is always returning the original create state on the button? – PkL728 Mar 16 '15 at 11:32
  • This case works. I added a event that modifies the enabled property of the button - Xamarin UI Test delivers the correct property value. Maybe I can test this behaviour also with a test-binding.. Its really weird – Michael Probst Mar 18 '15 at 09:34