TestProject Forum

How to validate toggle On and Off button in Mobile App

I have a toggle switch in my application image which is by default in toggled on state. I need to validate both on and off state of the toggle switch. Is there a way to validate? please help

Hello @ashok.acs

You can use the get text action on that toggle and this should return ON if the toggle is selected and OFF if the toggle is not selected.

Toggle is on:

Toggle is off:

Save the result to a parameter and use the result to identify if the toggle is ON or OFF.

Thank you so much this works. Is there a way where i can do the validation while getting the text? When the page loads by default the toggle should be in ON state. currently i can do this in multiple steps. i can get the text in one step and set the output result value as 1 (for me its not on and off instead it is 1 and 0) in the next step im calling the string contains and comparing it. Is there a way where i can simplify this?

I just got the solution. I used validation option and set the value as 1 and this solves my problem. Thanks again