Q:

How can I get all prefabs from a Assets folder? Getting not valid cast exception in the editor

GameObject[] prefabs = (GameObject[])Resources.LoadAll("Assets/Animations/Test");

The main goal is to get all the prefabs and also recursive in case there are sub folders under Test.

A:

Create directory Animations/Test inside Assets/Resources.
GameObject[] prefabs = Resources.LoadAll<GameObject>("Animations/Test");

It's going to get all files of type GameObject inside Test and its subfolders.

