Tests if the element is valid before trying to access it.