Recent discoveries of superconductivity in hydrogen-rich compounds stabilized by high pressures have shown that a critical temperature of superconductivity Tc can reach near room temperature values. The current studies focus on the search for new superconductors with higher Tcs to understand the ultimate limit of conventional superconductivity, and high-Tc superconductors at lower pressures. However, high pressure conditions put serious limitations on experimental studies. Electrical transport measurements have long been the primary experimental technique for reliable detection of superconductivity at high pressures, whereas magnetic susceptibility measurements continue to be a challenge. Here, we dramatically changed the protocol of magnetic measurements to probe the trapped magnetic flux. We tested this technique on samples of H3S and LaH10 and propose it for a routine examination of superconductivity at high pressures. Using the temperature- and magnetic field dependences of the trapped flux we estimated Tc ~195 K, a lower critical field ~0.36 T, an irreversibility field ~1.7 T, a full penetration field ~8.8 T, the London penetration depth ~37 nm, and critical current densities jc(T) in H3S at ~155 GPa in a wide temperature range. The trapped flux method is found to be sensitive to a particular phase in a mixture of superconducting phases: concomitant phases of sulfur and hydrogen-depleted LaHx were detected. In contrast to the Meissner state occurring at low external magnetic fields, a magnetic response from the trapped flux at zero applied magnetic field is in tens times stronger and is not contaminated by the magnetic background of a bulky diamond anvil cell. This technique can be a powerful tool for the screening of new superconducting materials, the study of multiphase, contaminated samples, or samples with a low superconducting fraction at ambient pressure too.