Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

IE & slow XPath #307

Closed
lukeis opened this issue Mar 2, 2016 · 24 comments
Closed

IE & slow XPath #307

lukeis opened this issue Mar 2, 2016 · 24 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 2, 2016

Originally reported on Google Code with ID 307

Please see the discussion here
http://groups.google.com/group/selenium-developers/browse_thread/thread/160a92fcacb12a62
for why this bug was opened.

In short, I noticed that if I include javascript-xpath.js (which is used
inside Selenium for XPath evaluation) in IE outside of selenium in my test
page, XPath evaluation is actually very fast when compared to doing the
same evaluation inside of Selenium. This is strictly for IE. For the
numbers that I observed, please see this post
http://groups.google.com/group/selenium-developers/msg/0ba13be20cc4d8a1.

I am including my test page along with the javascript-xpath.js in the
attached zip file. There are two tests you need to do wherein both evaluate
this XPath on the test page - "//table[@class='tblList']/tbody/tr" - I am
trying to find all the rows in that particular table.

1) Test outside Selenium: Load the test.html in IE (either locally or place
it on a webserver - remember to copy the javascript-xpath.js which is
included in the zip file) & click the "Run XPath" button. This will
evaluate the aforementioned XPath & display the time it took. You can take
a look at the JS to see what I am actually doing.

2) Test inside SElenium: I used Perl driver & you can use the
get_xpath_count() method to evaluate the above XPath, inside Selenium.
You'll notice that it is dramatically slow in the dual window mode &
slightly faster in singleWindow mode.

Hopefully, this test will demonstrate how something is making the XPath
evaluation (in IE) dramatically slower inside Selenium.

Reported by ivaturi on 2010-01-06 19:39:12


- _Attachment: [test-files.zip](https://storage.googleapis.com/google-code-attachments/selenium/issue-307/comment-0/test-files.zip)_
@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

There has to be something corrected in test.html.

Change

function main() {
  var start_ = new Date;
  var result = document.evaluate('//table[@class=\'tblList\']/tbody/tr', document,
null, 6, null);
  alert(result.snapshotLength + ' elements in ' + (new Date - start_) + ' [ms]');

};

to

function main() {
  var start_ = new Date();
  var result = document.evaluate('//table[@class=\'tblList\']/tbody/tr', document,
null, 6, null);
  alert(result.snapshotLength + ' elements in ' + (new Date() - start_) + ' [ms]');

};

Or you will always get 0 ms.

Reported by saschaschwarze.de on 2010-01-07 09:08:34

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

So if I understand you correctly, new Date & new Date() behave differently? I tried
to print the output of both those statements & I got the exact same output. 

Reported by ivaturi on 2010-01-07 18:55:32

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I used your test page to run some tests, and I'm not seeing the terrible numbers
mentioned in your link. I am using IE8, so it might be faster than the version you're
using - which is???

Here's the test I ran, with 100 iterations:

<<BEGIN

import com.thoughtworks.selenium.DefaultSelenium

class SeleniumTest extends GroovyTestCase {
    def selenium

    void setUp() {
        selenium = new DefaultSelenium('localhost', 4444, '*iexplore',
'http://localhost')
        selenium.start();
    }

    void tearDown() {
        selenium.stop()
    }

    void testIt() {
        selenium.open('/temp/xpath/test.html')

        for (i in 0..<100) {
            println "Iteration ${i+1}"
            assertEquals(17,
selenium.getXpathCount("//table[@class='tblList']/tbody/tr"))
        }
    }
}

<<END

Here are my numbers:

                  singleWindow  multiWindow
ajaxslt:          19.0s         195.4s
javascript-xpath:  5.2a          12.8s

As you can see, in either case (at least for this particular test case) the
javascript-xpath engine blows away the ajaxslt one. And the numbers are really not
too shabby.

Reported by hbchai on 2010-01-11 01:56:18

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I am using IE8 as well. So just to be clear, in your case it tool 12.8s to execute
that query 100 times?

Reported by ivaturi on 2010-01-11 02:40:25

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I ran the same test 100 times as you did & I got about 13 seconds for
javascript-xpath (multiWindow). But, I think there is a flaw in the test. My test
page already includes the javascript-xpath library. So I took that line out from the
test script & now that same test took 21 seconds.  

Reported by ivaturi on 2010-01-12 01:12:42

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I'm not sure I understand where you removed a line. Removing the reference to
javascript-xpath.js in the test page (and selecting javascript-xpath via
useXpathLibrary), my test still finishes in about 12 seconds.

Reported by hbchai on 2010-01-13 06:01:31

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Did you delete your browser cache? I can get close to 12 seconds only if the
reference to javascript-xpath.js is present in test.html. If I remove it, then delete
the browser cache & run the test in Selenium (multiWindow) I get close to 21 seconds.

Reported by ivaturi on 2010-01-13 19:04:07

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

OK couple of more tests, if you guys haven't already lost patience :)

1) In the test.html page remove the <script> tag that includes javscript-xpath. Make
sure you delete your browser cache. Then change the XPath in your script to
//table[\@class='tblList'][1]/tbody/tr. Note that all you are changing from previous
one is to add the array identifier to the table. I ran this test & I was able to run
it 100 times in 509356 ms or rather 509 seconds.

2) Now include that <script> tag back in to the test.html & run the same test again.
This time it took 22640 ms or 22 seconds to finish 100 runs. 

So one observation for me here is that XPath processing numbers get progressively
worse when you use array identifiers in your expressions. May be that has to do with
how javascript-xpath is implemented but that doesn't explain how they dramatically
improve when javascript-xpath is included in the app under test.

Reported by ivaturi on 2010-01-14 01:06:09

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I don't see how deleting the brower cache should change anything. At any rate, I
deleted it, and I'm still getting the same performance as before - that is, around
12
seconds.

Reported by hbchai on 2010-01-14 04:05:00

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I'm attempting to use  selenium-dotnet-2.0a5 to iterate through table cells, and have
to use xpath.

Average times to iterate through about 50 rows, firefox 1-2 sec, chrome 7-8 sec, IE
60-70 sec.

Most of my tests need to be run in IE, any tips on what can I do to get better xpath
performance?

Reported by Bond711 on 2010-09-14 01:11:20

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by dharani@google.com on 2011-01-21 19:54:42

  • Labels added: Performance

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Hi friends,
I am using selenium for functional testing. In my current application, there is a serious
need to run the tests on IE in fast mode. but IE taking more time to recognize the
objects as app is developed using SmartGWT. I read the above post but could not actually
get what to do for improving IE performance. 
Please suggest a way. Pls.....
My email - deepa.kiran1116@gmail.com

Regards
Deepa

Reported by deepa.kiran1116 on 2011-04-18 09:05:18

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Running in single-window mode seemed to solve all performance issues, but now we're
having security issues because of our HIDS when using single mode

Reported by nathan.christie on 2011-06-09 14:40:36

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I got slow selenium performence for IE and FireFox browsers when i updated the selenium
RC 1.0.3 server to selenium 2.0. Please fix this issue. 

Reported by inzerion on 2011-07-12 10:24:25

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Are you using the WebDriverBackedSelenium or have you also translated your tests to
use the WebDriver API? Or have you made no changes to your tests at all?

Reported by simon.m.stewart on 2011-07-12 14:31:25

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I made no changes at all. Only run new 2.0 server to support FF5. It all that I need
now. 

Reported by inzerion on 2011-07-26 09:56:22

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Same here - Selenium 2.4. Running the following code:

    @Test
    public void speed_test() {
           WebDriver seleniumIE = new InternetExplorerDriver();
           seleniumIE.get("http://bulgaria.craigslist.org/");
           System.out.println("IE Start: " + Calendar.getInstance().getTime().toString());
           System.out.println(seleniumIE.findElements(By.xpath("//a[@href]")).size());
           System.out.println("IE Stop: " + Calendar.getInstance().getTime().toString());

           WebDriver seleniumFF = new FirefoxDriver();
           seleniumFF.get("http://bulgaria.craigslist.org/");
           System.out.println("FF Start: " + Calendar.getInstance().getTime().toString());
           System.out.println(seleniumFF.findElements(By.xpath("//a[@href]")).size());
           System.out.println("FF Stop: " + Calendar.getInstance().getTime().toString());
   }

##### Got these results for FF 5 and IE 9:

IE Start: Thu Aug 18 18:27:43 EEST 2011
375
IE Stop: Thu Aug 18 18:27:52 EEST 2011

FF Start: Thu Aug 18 18:28:02 EEST 2011
375
FF Stop: Thu Aug 18 18:28:02 EEST 2011


Reported by kamenlitchev on 2011-08-18 15:30:29

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I'm also having very slow performance on IE9.

Firefox 6 and IE9 comparison (using *firefox then *iexplore)
- with FF6 : the test took  25.211 seconds
- with IE9 : the test took 548.116 seconds

For information :
- The tests are version 1.0 (not using the WebDriver API) and are running on the latest
Selenium 2.4.0 
- Single-window mode is not activated (false by default)
- Selectors are a mix of id and xpath, both look slow when the test is running


Reported by mark.kiami on 2011-08-23 12:26:51

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by barancev on 2011-10-12 18:24:48

  • Labels added: Component-RC, Browser-IE

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Hi,

Can you help me on how to automate the IE using selenium-perl.

I am currently using Selenium IDE 1.4.1 with perl formatters 1.0.0, selenium 2.15.0
server.

The thing is I am able to automate FF browser but chrome and IE are not working when
I launch my scripts.

I run C:\Users\esrirsa\Downloads\Selenium>java -Dwebdriver.chrome.driver=C:\Users\esri
rsa\Downloads\chromedriver_win_16.0.902.0\chromedriver.exe -jar selenium-server-
standalone-2.15.0.jar

And then I launch my perl script. But I am unable to automate it in IE.
Can you give me any details and commands to run the IE?
In chrome I am able to launch the scripts now except for the site developed by company.
It is in the Issue 3053.

Can you please take a look and help me to solve it.

Regards,
Anurag

Reported by anuragsatishcse on 2011-12-13 09:37:23

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

All active development is focused on Selenium 2.0 (the WebDriver APIs).  Updating issue
priority accordingly.

Reported by jmleyba on 2012-01-04 03:06:21

  • Labels added: Priority-Low

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

I guess this is related to http://code.google.com/p/selenium/issues/detail?id=2690

Reported by TCBlues on 2012-02-10 11:07:50

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Selenium RC is deprecated and no performance issues are going to be fixed.

Reported by barancev on 2013-10-29 22:42:18

  • Status changed: WontFix

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by luke.semerau on 2015-09-17 17:48:08

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 2, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 3, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant