Why Selenium script runs slow on IE browser as compared to other browsers like chrome and Firefox?

Why execution speed of Selenium in IE is slow?

If we are talking about execution speed then i would go with headless browser and htmlunit is a headless browser.

So as per my working experience have got that scripts in almost all browser get executed at the same rate except few of the exception in IE. But if we are going to include the browser up time then order is like this,

htmlunit –> Chrome –> Firefox –> at the last its IE

Now, why IE is slow?

Much of the functionality of WebDriver is implemented using so-called “automation atoms”. These are JavaScript functions that are used to ensure consistency and reduce maintenance across the different drivers. Some of these functions are fairly straightforward, and delegate down to the browsers’ native code fairly quickly. Finding an element by ID, for example, pretty clearly translates to document.getElementById().
Other operations, on the other hand, are much more computationally expensive. For example, getting the text of an element is one of the most expensive things you can do, Because of the way the WebDriver API defines getting an elements text.
Because so much of this functionality is built in JavaScript, a browser that has a slow JavaScript engine like IE Will show poor performance when executing WebDriver code. Remember that the JavaScript engine in IE before version 9 was about ten times slower than the JavaScript engines in Firefox and Chrome. IE9 introduced a new JavaScript engine that was a lot closer in performance to that of Firefox and Chrome, but Microsoft only implemented the new JavaScript engine in the 32-bit version of IE. So the first thing you can do is run your tests against the 32-bit version of IE9.
IE also doesn’t have a native XPath engine for finding elements. So to be able to find elements by XPath in IE, we have to use a JavaScript XPath query engine. That’s going to be slower than doing the same thing in other browsers. This is the biggest reason why I recommend using CSS selectors instead of XPath for finding elements.
I would also recommend calling expensive methods as seldom as possible. The two most expensive methods are getText() and isDisplayed(), because they have to walk a substantial portion of the DOM tree before they can return the correct value.

 

Leave Comment

Your email address will not be published. Required fields are marked *

Looking for learning Framework Development from Scratch? Lookout for Detailed Framework Development videos on YouTube here -

https://www.youtube.com/automationtalks

Get the Framework code at Github Repo: https://github.com/prakashnarkhede?tab=repositories