Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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

share|improve this question
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 Dec 26 '12 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 Dec 26 '12 at 17:18
add comment

closed as not a real question by corsiKa 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.

1 Answer

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.

share|improve this answer
add comment

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