This may save you from having to purchase a new switch.
DONT pull the tube out of the drum or you could have a leak, that 's why I said GENTLY. All washing machines have a pressure switch, it is a rubber tube leading into the outer drum and up to the switch, located up on the frame top rail under the lid, if this tube becomes blocked with dried detergent suds it wont function, gently pull of the rubber tube from the switch and suck and blow through if you can or push a piece of flexible electric wire through it then blow it again and reconnect and test.