Aims. In this paper we investigate the detectability of the molecular oxygen in icy dust grain mantles towards astronomical objects. Methods. We present a systematic set of experiments with O-2-H2O ice mixtures designed to disentangle how the molecular ratio affects the O-2 signature in the mid- and near-infrared spectral regions. All the experiments were conducted in a closed-cycle helium cryostat coupled to a Fourier transform infrared spectrometer. The ice mixtures comprise varying thicknesses from 8 x 10(-3) to 3 mu m. The absorption spectra of the O-2-H2O mixtures are also compared to the one of pure water. In addition, the possibility to detect the O-2 in icy bodies and in the interstellar medium is discussed. Results. We are able to see the O-2 feature at 1551 cm(-1) even for the most diluted mixture of H2O:O-2 = 9:1, comparable to a ratio of O-2/H2O = 10% which has already been detected in situ in the coma of the comet 67P/Churyumov-Gerasimenko. We provide an estimate for the detection of O-2 with the future mission of the James Webb Space Telescope (JWST).