I want to perform automation (selenium) using Xpath. Which one gives better results?
closed as not a real question by corsiKlause Ho Ho Ho♦ Dec 26 '12 at 17:16
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.
I assume you use the terms as defined in the Xpath specification. In that sense, absolute and relative paths are not interchangeable. You use a relative path when you refer to something relative to another element. The rest of the time, you use an absolute path.
It is possible that you really want to understand the relative merits of an absolute path and an abbreviated absolute path. The former starts with a single slash, whereas the latter starts with a double slash followed by a relative path. You use an abbreviated absolute path when you want to describe a location relative to the root but you do not want to specify all of the ancestor elements.
It is possible that your web page may change someday, e.g. because a developer updates it or because it contains dynamically generated id's. An abbreviated absolute path may be more likely to still work with the changed page than an absolute path. It may also be easier to read.