A finite-element method is presented for calculating the quantum conductance of mesoscopic two-dimensional electron devices of complex geometry attached to semi-infinite leads. For computational purposes, the leads must be cut off at some finite length. To avoid spurious, unphysical reflections, this is modeled by transparent boundary conditions. We introduce the Hardy space infinite-element technique from acoustic scattering as a way of setting up transparent boundary conditions for transport computations spanning the range from the quantum mechanical to the quasiclassical regime. These boundary conditions are exact even for wave packets and thus are especially useful in the limit of high energies with many excited modes. Yet, they possess a memory-friendly sparse matrix representation. In addition to unbounded domains, Hardy space elements allow us to truncate those parts of the computational domain which are irrelevant for the calculation of the transport properties. Thus, the computation can be done only on the region that is essential for a physically meaningful simulation of the scattering states. The benefits of the method are demonstrated by three examples. The convergence properties are tested on the transport through a quasi-one-dimensional quantum wire. It is shown that higher-order finite elements considerably improve current conservation and establish the correct phase shift between the real and the imaginary parts of the electron wave function. The Aharonov-Bohm effect demonstrates that characteristic features of quantum interference can be assessed. A simulation of electron magnetic focusing exemplifies the capability of the computational framework to study the crossover from quantum to quasiclassical behavior.