Search code examples
cucumbercalabash-android

calabash-Android - multiple instances of same radioButton - how to assert?


I am testing an android form (xamarin).
My script looks for a radioButton with a label ="Registered" It finds and performs action on this However there is another instance of a radioButton labelled "Registered" which is several lines below the 1st instance. The cucumber script is always finding the first one only, therefore the script fails.

I need to perform actions on both buttons not just the first instance.

When I do a query("RadioButton") it returns just the one radio button, as on the form the C# code is simply instantiating another instance of the one radioButton. We do not wish to change the code if need be, so I was wondering is there anyway in Cucumber/Calabash to ignore the 1st instance and perform and action on the second instance? Thank you.


Solution

  • If the element you want is inside another element, you can use the query syntax to chain together locators. e.g.

    query(ListView index: 1 * RadioButton)
    

    Using this you could find the one that you want.

    That said, query("RadioButton") should return two elements if there are two currently on the screen. The way the query method works shouldn't care if it's the same element in the c# code. If the element isn't on the screen then query won't return it, so you may need to scroll down/across etc.