Are you using that code snippet within a loop maybe, where the field may or may not be filled? Even if the field is populated, if the variable is not a page object, you can’t call the url()
method on that. It is good practice to get into a habit of checking if an object exists before you try to call a method on it, you never know what happens to fields or pages later on.