I've done it, but only on non-computerized vehicles.
I always did it with the engine running, so I knew what got wet when/if the engine died.
I also tried to avoid spraying directly at the carb, dist, and alt, for obvious reasons.
Too many things to avoid with all the connections on computerized engines!
I have never done it and I hate water on an engine. My engine needs cleaned bad and a good steam or hose down would do wonders, but i'm not going to do it. I have seen guys soak the engines. When I was a service advisor at a BMW dealer we would tell people that we will not clean the engins as part of a detail due to many cars not starting for days afterwards.