- This topic has 2 replies, 2 voices, and was last updated 2 years, 9 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
Home › Forums › Software Testing Discussions › Selenium Object Locator
How often and when do you like to use XPath?
I was always advised to give least importance to XPath (structure based locator)
Not very often, but I don’t hesitate to use it where it suits me. Years ago people talked about XPath performance problems, in the same time in my tests I found that CSS pseudo-classes do not work for me in some browsers. A few years ago one guy posting to automation community tested performance of the two types and his conclusion was that XPath performance is as good as CSS selectors (providing both are built reasonably). Support of CSS pseudo-classes also developed.
So — use whatever suits you, the most important thing IMO is that your locators look reasonable and are bound to some well-marking attribute, not just to the structure.
@rpwheeler, thanks for your comment. Yes, I understood that as long as our locators are reliable we are good to go with whatever that suits our purpose.
Also to start with an ‘anchor’ which is not likely to change is one of the best practice I follow.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.