Learn how your appliance is supposed to operate so you can determine if it is malfunctioning.
A solenoid is simply an electromagnet. The solenoid coil consists of a loop of wire inside a plastic housing. Through the center of the coil is a tube with an actuator inside. When the coil is powered the magnetic field created moves the internal actuator, opening a passage for gas to flow. When power is removed, the actuator returns to its 'home' position closing the passageway and stopping gas flow.
Should the wire the solenoid consists of break, no magnetic field can be created and thus the gas valve will not operate. Sometimes however that breakage only occurs with use. The coil can heat when powered. As it heats the internal metal wire expands. If there is a break in that wire, the heat can cause the gap to expand and open the electrical circuit which stops gas flow. Sometimes that separation will close again once cool to allow the coil to function again for a short period until the failure repeats.
The solenoid coils of gas valve assembly are easily serviceable however replacement coils for the older "K" series valve may be hard to find these days. Most current model dryers use the more compact "M" serial gas valve. The coils for the "M" series valve are sometimes sold individually or together in a set. The coils from any of the manufactures should be equivalent to each other and interchangeable as they all come from the gas valve manufacturer White Rodgers.
If the solenoid coils of your "M Serial" gas valve fail or are intermittent, the Whirlpool solenoid kit part number 279834 is often the most cost effective replacement. However, if you want to use the OEM replacement parts, here are links to the General Electric (part number WE04X10020) and Frigidaire (part number 5303931775) equivalents.
If you need coils for an older "K Series" dryer gas valve, use the model number to look up if the correct replacement parts are still available.
All of the information in these Appliance Clinic procedures is provided FREE OF CHARGE. No liability is assumed by the author for the accuracy of the contents or damages caused by the use of these procedures.