3

I've found out that people use JQuery element-locators in Selenium. I like the idea and I'd like to ask about benefits from using JQuery selectors instead of XPath ones. Are they more "flexible" or fast, let's say in Firefox or Google Chrome?

1
  • Without specific use case this is subjective Commented Dec 3, 2010 at 15:26

2 Answers 2

1

Based on my small experience with selenium I have some arguments against XPath:

  1. XPath is slow in FireFox and painfully slow in IE (I have observations on IE7). My tests which use mostly XPath run ~2.5 times slower in IE7 than in FF.

  2. With XPath selectors you are more likely to run into browser dependent problems. I have two examples:

I hope this was useful.

Cheers!

Sign up to request clarification or add additional context in comments.

3 Comments

Many thanks for your answer. Have you tried using JQuery locators?
Nope. We used DOM locators several times. They are much faster and reliable than XPath but tend to be more difficult to create and maintain as you can see in my post :-)
Concur painfully slow in IE. But what is your basis for saying that XPath is slow in Firefox? I have done lots of measuring (2GHz PC), and I see 0-2ms for most expressions, and 10s of ms for very complex/nested expressions.
1

For Selenium in IE try using single-window mode. This brings up the main window to speed with FF and keeping popups as slow as they were originally in IE. Overall, this increases the speed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.