-2

I want to perform automation (selenium) using Xpath. Which one gives better results?

2
  • 1
    Welcome to SQA.SE - perhaps you'd like to expand your question, to explain what you ARE trying to achieve? At the moment, it just seems brusque.
    – Andrew
    Commented Dec 26, 2012 at 14:12
  • I have to agree with Andrew here. If you could elaborate on what the business problem you're trying to solve is, perhaps this could be salvaged into a keepable question. You can still edit the question even though it is closed, and I'll be more than happy to reopen it when it's ready for consumption! :)
    – corsiKa
    Commented Dec 26, 2012 at 17:18

1 Answer 1

2

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.