Automatically distinguish between various two terminal components
As long as you limit the power you apply to the DUT, you won't destroy it.


  detecting polarity of a capacitor without applying reverse voltage


You can't. The only way to determine the polarity is to look for the increased leakage current under reverse bias. As long as you keep the current low (microamps), this won't destroy the capacitor.


  First idea for a zener was (after detecting it is a diode) that I
  detect the breakdown voltage, but what if it is just a normal diode
  that gets destroyed this way because it has a rather low breakdown?
  That would limit the breakdown voltage that I could detect in zeners.


Again, if you limit the current to a suitable value, you won't destroy a diode, even under reverse breakdown. For example, suppose you want to limit the total power to 100 mW. If your diode is breaking down at 40 V, you need to limit the current to 100 mW / 40 V = 2.5 mA.