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.
Well, there are multiple reasons. Here are few in no particular order
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?
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.
Due to the above mentioned reason, webdriver tests are faster than Selenium
Its much easier to extend webdriver compared to selenium. Webdriver provides extendable action classes which you can combine and create your own customized actions.
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
What A.J. said.
There are limitations on RC that can't be overcame easily.
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.
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.
Because of another security policy in Javascript, you can't fill in <input type='file' />
inputs and have to use several workarounds.
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.
You can't really maximize the window in RC :).
You have to write your own methods when you need to wait for an element.
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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With