What is new in Selenium 2 February 19, 2011
Selenium 2 is still in beta but we now have a decent idea of what is coming in its next release. Here is the gist of it:
A new and more expressive API
The Selenium API has changed in Selenium 2. One very noticeable change is that in Selenium 2 we now have getters for html elements which we can perform actions against. In Selenium 1 and earlier, the apis performed actions directly on the locators.
Browser specific drivers
What this in turn allows is:
- Native keyboard and mouse interactions. This mimics the end user interactions with the browser much better than what earlier versions of Selenium provided, while being faster and more stable.
- Problems related to Same origin policy in Selenium 1 are now gone.
- Better support for handling popups and dialogs. This includes some big problem items like upload and downloads.
Mobile web support
Selenium 2 now supports running tests in mobile devices. IPhone and Android are the two platforms supported. The way it works is that you would have to install an app (a mini selenium server) on the device. This listens for commands which then drives the web browser within the app.
This mechanism however will not allow us to test native apps in these devices.
Selenium 2 is still a web automation tool but it now does allow a few interactions with the OS. These interactions are related to the web browser though. For instance, you could potentially interact with the OS to handle invalid SSL warnings.
No need to start Selenium server
When you start using the new WebDriver API, you don’t need to run the Selenium server. Infact if you just have the WebDriver API jar (selenium-java-2.5.0.jar for instance) in your classpath, you wont have the classes required to start the selenium server. For that you will need to download the standalone server jar file as well.
If you use the Selenium-backed WebDriver i.e. using Selenium 1 API but Selenium 2 jar (yes this is supported too), or you need to use Selenium Grid, you would still want to run the server. You would choose this option if:
- You dont have the time to refactor your code to use the newer webdriver APIs, but need support for the latest browsers.
- You are using selenium grid that allows disributed test execution.
However, if you don’t use the new WebDriver APIs though, you will loose the other Selenium 2 benefits you get that were mentioned above.
Upgrade or not?
If you are starting to implement web test automation, I would recommend using Selenium 2 for sure.
The question about upgrade is not as simple an answer as I would like it to be. On one hand, the Selenium contributors seem to be spending a lot of time ensuring there is backward compatibility. Infact, it is one of the reasons why the final release is taking longer. On the other hand, the changes in Selenium 2 are very significant. In some ways it almost feels like it is a completely different tool. So I would expect to see some issues early on. I have started using Selenium 2 recently and as I get more data, I will update this page so stay posted.Selenium