I figured it out. But I thought I should leave it here since it might be the cause of quite some confusion. The key is to use the in-build tap_and_hold method.
def switch(switch_view)
tap_and_hold(switch_view)
sleep 1 # For the animation
end
You can combine this with prior information about the state and create definite tests as well.