Can price be negotiated and agreed 100% before going for test drive?

Is this a bad idea?

If you have a 150 mile drive to where a used car is - I know you're not supposed to let it be known that you are in this situation at the dealer - because they know you do not want to have to make that drive twice etc.

On the other hand - instead of driving to a dealer far away and trying to negotiate - can you call/email them and say I'm interested in this car but I am far away - I am not coming there until we have agreed on a price...

Can this work or is this a scenario where you could do it but you would never get a good deal this way?