This will be the problem for most washer, the washing machine will not spin, agitate, or both when the lid switch breaks. The lid switch usually goes out slowly.
Slamming the lid will get it to work for awhile.
Most whirlpool washer styles this will affect both agitate and spin but some models will still agitate but not spin.
This is easy to check. You will need to remove the switch, this varies with model type but the testing will be the same.
When the lid is closed the switch should have continuity when the lid is opened the switch should have no continuity.
If it differs replace the Lid Switch.
Water Level Control / Pressure Switch
This could cause a washer to agitate but not spin. Not likely though.
To check this on most , with no water you should have continuity on pins 7 & 15. With the tub full 7 & 16 should have continuity.
This video walks you thru checking another type of switch.
To check the washing machines timer you will need to refer to the wiring diagram or disassemble to access the motor.
Check the leads from the timer to the motor when turned to a wash cycle this should have 120 volts.
If not replace the Timer, if it does the timer is not the problem.
To check the motor you will need to disassemble the washer to access the motor.
First you can check the motor windings, to do this remove the plug and connect multimeter to terminals.
Refer to the tech sheet or service manual for the proper reading.
Check washing machines motor for shorts by connecting your multimeter to the washers motor terminals and motor housing should have no continuity.
Connect your voltmeter to the washers motor wire connectors and check for voltage.
You should have 120 volts, if you do and the washing machines motor still does not run, replace the washers motor.
If it does not have power the problem is elsewhere.
Try the washers motor capacitor.
If your washer is a belt drive type make sure the belt is tight.
Check for black soot from belt wear.
Replace the Washing Machines belt if it has excessive wear and tear or is broken.
This is a fairly common problem with direct drive washing machines, good thing its inexpensive and easy to replace.
The Washing Machines Motor Coupling transfers power from the motor to the transmission. It is located between the motor and the transmission.
The following video will walk you through the replacement of the Motor Coupler.
The washers transmission does not fail that often.
To check this on a direct drive washer remove the motor and then turn tub inside the washing machine.
If it spins freely with no noise the problem is elsewhere.
If your washing machine is still noisy it needs replacing of the transmission, this is expensive and depending on the age of your washing machine you may not want to replace it.
On a belt drive washing machines remove the belts and spin tub from the washer.