Magic wavelengths, for which there is no differential ac Stark shift for the ground and excited state of the atom, allow trapping of excited Rydberg atoms without broadening the optical transition. This is an important tool for implementing quantum gates and other quantum information protocols with Rydberg atoms, and reliable theoretical methods to find such magic wavelengths are thus extremely useful. We use a high-precision all-order method to calculate magic wavelengths for the 5s-18s transition of rubidium, and compare the calculation to experiment by measuring the light shift for atoms held in an optical dipole trap at a range of wavelengths near a calculated magic value.