If we omit the batteries, there have been electric buses since forever - trolley buses. They come also in hybrid variants too to serve more distant bus stops.
You're can do trolley buses with batteries as well, which charge while passing through central parts of their lines with overhead power, and discharge during the rest of their journey.