Xamarin.UITest - how to assert if button is disabled RRS feed

  • Question

  • User395396 posted

    Hi All, is there a way how to assert if button is disabled? If I query for a button I can see property called Enabled, but that is always true, even if button is not clickable, so I can not use that.

    From our devs I found out that they are using property IsActive to determine if button is clickable or not.

    But I don't see such property when using REPL. How do I find out if button is clickable or not?

    Thank you.

    Wednesday, August 5, 2020 12:46 PM

All replies

  • User379860 posted

    Based on your code about the IsActive, do you create a ContentView as a customView, then add the Button to ContentView?

    IsActive is property add to the ContentView.

    You can add a x:Name="ElementName" to your Button in the ContentView , then use following code to check it.

    app.Query(c => c.Id("ElementName")).FirstOrDefault().Enabled

    Wednesday, August 5, 2020 1:48 PM
  • User395396 posted

    Hi @LeonLu , thanks for the answer. I also have an AutomationId for that button, so I can do same thing with :

    app.Query(c => c.Marked("saveButton")).FirstOrDefault().Enabled;

    but seems like that will only give back value of Attribute "Enabled", which as I mentioned is always "True" :(

    I also tried to add Name as you suggested but same result. Query will then return value of "Enabled" which is always "True"

    Thursday, August 6, 2020 8:58 AM