Two common causes of intermittent issues in power supplies:
A broken cord or connector. In addition to the tests you tried, wiggle the plug that goes into the laptop gently to see if the charge light goes on or flickers.
A component in the power supply pulling loose from a PC board. If tapping the power supply makes the charge light flicker, that's a likely culprit.
If you are comfortable taking apart the laptop to fix the connector, or have tools and skills to fix a power supply (these are usually potted and difficult to open), you can try to fix these. If it's the laptop's DC power connector, and that is beyond your skills, find a local repair shop.
However, if it's just the power supply and/or its connectors, a replacement "universal" power supply can be bought for ~US$10, depending on the specs. Match the voltage output of the present supply, and equal or exceed the current needs.