12

I am planning to run my existing Selenium 1.x tests in IE 8.0.

After checking few blogs and reading this, I tried to run my tests using jQuery locators with the method mentioned here. My tests uses a lot of index based selectors, like in xpath=div[class='myclass][index].

In jQuery I tried .myclass:eq(index) to retrieve the elements. But I found jQuery to be much slower than XPath in IE and Firefox for these operations. Is there a faster way in jQuery to select nth element?

dzieciou
10.5k9 gold badges49 silver badges102 bronze badges
asked Jun 30, 2011 at 15:53
4
  • 1
    I don't have any metrics but I would expect CSS to be the fastest in IE8. jQuery has a JavaScript dependancy, as does XPath in IE8 (As IE8 doesn't support XPath nativly so has to run through a JavaScript libraray). IE's JavaScript performance is lacking. Commented Jul 1, 2011 at 9:55
  • And IE xpath is not reliable. For example I found that in my test when I do By.name("soemName") it finds WebElement, and when I do By.xpath("//input[@name='soemName']") it doesn't. On FF both work perfectly. Commented Jul 7, 2011 at 14:04
  • Are you sure the name doesn't have spaces in it? Does By.xpath("//input[contains(@name,'soemName')]") work? Commented Jul 12, 2011 at 8:20
  • The post on stackoverflow.com/questions/4346479/… tells more about doifferent locators performance Commented Nov 2, 2012 at 21:42

3 Answers 3

3

No jQuery will not be faster.

IE has a very slow JavaScript engine compared to other modern browsers. Using jQuery selectors means you are using JavaScript to query the DOM, so you are instantly limited by IE's JavaScript engine. XPath support in IE is also via a JavaScript library (Google's wicked good xpath library), so XPath's will also be slow.

The fastest locator strategy in IE is CSS because of its native support, of course different versions of IE have differing support for CSS and as a result different CSS locators are supported in different versions of IE.

All of the above makes IE an absolute joy to automate... ;)

answered Feb 8, 2013 at 11:33
-1

We use the following three different locators in the project

XPath using Ajaxslt library XPath using Javascript library jQuery Selector The tests are created from Tellurium Issues page and include three sets

A series of test flow including issue search and issue data access Similar to the first one but without group locating in UI modules Access data from the issue table (limit the size to 20 rows and 10 columns)

http://code.google.com/p/aost/wiki/TelluriumjQuerySelector


How to enable custom jQuery selectors in robotframework-seleniumlibrary

Selenium Library 2.3 introduces an ability to register and use a custom location strategy to locate elements on the website. The new strategy must be loaded by selenium-server.jar. This guide will explain how to enable location strategy based on jQuery.

http://code.google.com/p/robotframework-seleniumlibrary/wiki/jQueryElementSelectors

answered Jan 10, 2012 at 9:41
1
  • 1
    -1: because The question was rather about performance of different locators types, and your answer does not relate to that at all. How does your post answer the question? Commented Aug 31, 2013 at 15:16
-1

I did some analysis long time back on CSS, jQuery and XPath and I feel jQuery is not giving better results than CSS and XPath. and CSS is little faster than XPath.

dzieciou
10.5k9 gold badges49 silver badges102 bronze badges
answered Jan 30, 2012 at 5:29
1
  • -1 because answer is not backed up by any facts or link, so it sounds like a subjective perception of performance. Commented Aug 31, 2013 at 15:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.