I have put down an electric train with power nearby, but as soon as it pulls away from the station, it says that it's out of fuel. I feel like I'm missing something silly.
I'm not planning on using the battery packs because it's not a long ride.
You need to set up a schedule for the charging to work. When the train stops at a station on an automated schedule the script does some magic to make it draw power from the grid.