I think in modern day Japan 電車 refers to all trains. At least that's my impression from discussing it with my Japanese fiancée. I think more accurately, different terms were used in the past but now でんしゃ is the common word for train, rather than an electric train specifically.
However, the difference is trivial now that the vast majority of trains operating in Japan are electric. They will be more specific for the service they are travelling on such as subway, JR, and high speed services 新幹線「しんかんせん」(known as "bullet train" in English).
Note that Japanese people tend to refer to the company or service offered rather than the physical train. It's basically assumed you will travel by train unless you specify driving or flying. They have JR lines, subway, and metro lines running underground. That's not a typo: Tokyo has both Metro and Subway lines, depending on the company operating the lines. It is not a matter or whether you use "Subway" or "Metro" if you are American or European. You will be referring to different specific lines in Tokyo as several companies operate there.