[UITest 0.7.2 & Forms 1.4.1] Get value from switches?

MartinManMartinMan DKMember

I have an application with a short setup first time you start the application. In this setup you are able to enable or disable Insights with a switch.
This choise can later be changed in a Settings menu, where the switch will have the value originaly set.

However i'm unable to read the value in my UI tests. When I query or use tree to inspect the element, it's identical if it's on or off.

Is there any way to check the value of a switch?

Tagged:

Best Answer

Answers

  • CaitlinCaitlin USMember ✭✭

    This was very helpful. I would just like to add that you can also use
    c => c.Marked("YourStyleID")
    instead of
    c => c.Class("Switch")
    if that is more useful for you.

  • JohnHardmanJohnHardman GBUniversity mod

    @prashantvc - Many thanks for that. One follow-on question - if you had multiple Switch views on a page, and wanted to get them all to a known state (let's say we want them all set to off), how would you do that?

    I can identify them individually and change their state, but I feel like there must be a simpler way, using linq.

    Many thanks,

    John H.

  • pranartdechpokketpranartdechpokket THMember ✭✭

    I use library named "FormsTest" (https://github.com/pranart/FormsTest)
    This library will let you get almost every property value from Xamarin.Forms Controls.
    

Sign In or Register to comment.