Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obvious reason to move from Selenium RC to Webdriver.?

From past 4 months am doing automation testing using Selenium RC.

But recently i came to know that Selenium RC is deprecated. So many people suggested me to change to Selenium Webdriver.

So, can anyboby tell me whats the problem with Selenium RC and how Webdriver is better than RC ??

Thank you.

like image 514
Ranadheer Reddy Avatar asked May 28 '12 05:05

Ranadheer Reddy


2 Answers

Well, there are multiple reasons. Here are few in no particular order

  1. Webdriver offers a cleaner API than selenium RC. The most common example is you have selenium.type and selenium.typeKeys, both does the same thing in effect. Webdriver offers just one method sendKeys for all type related action. In short you can say, webdriver classes are better organized?

  2. Selenium works using javascript injection. If you have worked with selenium for sometime, then you must be aware of the same origin policy issues and limitations of javascript injection. Webdriver overcomes this by using a driver for each browser. For firefox this means, webdriver attaches itself to browser as an addon, for IE it uses automation atoms and for chrome and opera it uses the chrome driver.

  3. Due to the above mentioned reason, webdriver tests are faster than Selenium

  4. Its much easier to extend webdriver compared to selenium. Webdriver provides extendable action classes which you can combine and create your own customized actions.

  5. Webdriver can support testing in mobile devices such as Iphone, ipad and android phones and tablets.

Last but not at all the least, there is no development work happening in selenium project now. Whatever is available now, will continue to be supported but no new methods or enhancements are happening for selenium. Selenium and webdriver projects were merged some years back and became Selenium 2.0

You can find additional details about webdriver here and reason for merger here

like image 142
A.J Avatar answered Sep 23 '22 13:09

A.J


What A.J. said.

There are limitations on RC that can't be overcame easily.

  1. The extendability is a great issue. I seriously can't stress that enough. When I expanded some of the RC methods to do more work they did normally, I bumped into a barrier that could not be passed easily. What could be done in RC with 750 lines of code and heavy use of the Command pattern, can be done in WebDriver with just a few simple methods.

  2. The same origin policy. It is a Javascript security policy that allows running the code only from the domain you're on. And since RC is fully written in Javascript, you can't easily switch between domains or work with some websites that redirect or use frames with content from many domains.

  3. Because of another security policy in Javascript, you can't fill in <input type='file' /> inputs and have to use several workarounds.

  4. You can't work well with onload Javascript modal dialogs. Those, again, have to be worked around.

    Selenium tries to conceal those dialogs from you (by replacing window.alert, window.confirm and window.prompt) so they won’t stop the execution of your page. If you’re seeing an alert pop-up, it’s probably because it fired during the page load process, which is usually too early for us to protect the page.

  5. You can't really maximize the window in RC :).

  6. You have to write your own methods when you need to wait for an element.

  7. RC is no longer developed, there will be nothing new. It took some time for WebDriver to catch on on all the features, but now the time has come that WebDriver finally can offer slightly more than RC (the waits and maximizing). And it will get only better!

  8. The RC's getEval() method is a poor cousin of WebDriver's executeJavascript(). The former returns a String and can't be given e.g. a specific page element. The latter one can return directly many in-built language data structures, WebElements, Lists, and can take those as arguments, too! That means that you can find an element with WebDriver and then run some JS on it. With RC, you would have to locate the element with JS, too. That can be done, but is harder and much more error-prone.

That's mostly it. There is a reason NOT to switch, too: the WebDriver API is young and is still changing. Sometimes, there is a slight behavioral change when they fix a bug. Therefore, sometimes, it's a pain in the ass to upgrade and discover that it broke something.

That said, I would not go back to RC since WebDriver is so nicer to work with. And I am looking forward a lot for a time next year when WebDriver will hopefully have its most annoying oddities fixed.

like image 28
Petr Janeček Avatar answered Sep 22 '22 13:09

Petr Janeček