Take the battery out and just connect the charger. Does the laptop work fine? If yes then the battery is the problem. To test the charger run the HP Diagnostic:
Test the AC adapter using the UEFI Hardware Diagnostic tests
If the computer starts and you would like to test the AC adapter, use the following steps:
- Make sure the power cord and adapter is connected to the system and wall outlet.
- Press and hold the power button until the computer turns off completely.
- Turn on the computer.
- Immediately press the F2 key repeatedly, about once every second, until the UEFI Hardware Diagnostics screen is displayed.
- In the UEFI Main menu, select Component Tests.
- In the Component Tests menu, select Power
- In the Power menu, select the AC Adapter test.
- Run the test and follow the onscreen instructions.
- When the test is finished, the results display.
- If the test PASSED, there is no issue with the AC adapter.