Consider the electromagnetic scattering of a time-harmonic plane wave by an open cavity which is embedded in a perfectly electrically conducting infinite ground plane. This paper is concerned with the numerical solutions of the transverse electric and magnetic polarizations of the open cavity scattering problems. In each polarization, the scattering problem is reduced equivalently into a boundary value problem of the two-dimensional Helmholtz equation in a bounded domain by using the transparent boundary condition (TBC). An a posteriori estimate based adaptive finite element method with the perfectly matched layer (PML) technique is developed to solve the reduced problem. The estimate takes account both of the finite element approximation error and the PML truncation error, where the latter is shown to decay exponentially with respect to the PML medium parameter and the thickness of the PML layer. Numerical experiments are presented and compared with the adaptive finite element TBC method for both polarizations to illustrate the competitive behavior of the proposed method.