We present a simple method for obtaining elastic scattering phase shifts and cross sections from energies of atoms or ions in cavities. This method does not require calculations of wavefunctions of continuum states, is very general, and is extremely convenient from practical point of view: some conventional computer codes designed for the energies of bound states can be used without modifications. The application of the method is illustrated on an example of electron scattering from Kr and Ar. From Brueckner orbital energies in variable cavities, we have obtained ab initio cross sections that are in close agreement with experiment. The relativistic effects are also considered and found to be small below 10 eV.PACS numbers: 34.80. Bm, 31.15.Ar, 31.30.Jv Conventional methods of calculations of scattering cross sections are cumbersome, inconvenient, and very often inaccurate. This is only because they all are based on computing continuum, or sometimes quasicontinuum, wavefunctions and asymptotic fittings to extract phase shifts. Such an approach requires modifications of conventional atomic structure codes, developed for bound states, or just writing new programs altogether. For a known potential it is not a difficult task -this is why numerous semi-empirical calculations can be found in the literature -but the level of accuracy and theoretical uncertainty of calculations based on ad hoc potentials can not be totally satisfactory. For ab initio calculations already complicated codes have to be rewritten, which takes considerable amount of time. For multiconfiguration Hartree-Fock (MCHF) method this was undertaken by Saha [1, 2] to obtain ab initio results in agreement with experiment. However, many-body perturbation theory (MBPT) methods, which were developed for fundamental symmetry tests, have not been used for calculations of electron scattering cross sections.The method we propose in this letter is very simple and general: instead of finding continuum wavefunctions and fitting them to asymptotical solutions to obtain phase shifts for given electron energies, we impose a boundary condition on an atom, an ion, or a molecule to make the spectrum discreet and then from discreet energies extract phase shifts which are uniquely related to these energies. Thus the problem of phase shifts is converted into a conventional problem of finding energies of bound states. Especially simple relation exists, as we will show, in the case of an atom in a spherical cavity.It can be shown that continuum and quasicontinuum wavefunctions are equivalent. For example, in Ref. [3] it was stated that B-spline solutions obtained in a cavity can be interpreted as a representation of true continuum states with a different normalization, and the energy of the quasicontinuum states can be set to an arbitrary positive value by adjusting the size of the cavity. There are also other methods that give B-spline continuum wavefunctions at any energy: the Galerkin method [4], leastsquares approach [5,6], and free boundary condition approach [7]. ...