By performing quantum molecular dynamics (QMD) simulations, we investigate the equation of states, electrical and optical properties of the expanded beryllium at densities two to one-hundred lower than the normal solid density, and temperatures ranging from 5000 to 30000 K. With decreasing the density of Be, the optical response evolves from the one characteristic of a simple metal to the one of an atomic fluid. By fitting the optical conductivity spectra with the Drude-Smith model, it is found that the conducting electrons become localized at lower densities. In addition, the negative derivative of the electrical resistivity on temperature at density about eight lower than the normal solid density demonstrates that the metal to nonmetal transition takes place in the expanded Be. To interpret this transition, the electronic density of states is analyzed systematically. Furthermore, a direct comparison of the Rosseland opacity obtained by using QMD and the standard opacity code demonstrates that QMD provides a powerful tool to validate plasma models used in atomic physics approaches in the warm dense matter regime.