The final version of Selenium 2.0 was released yesterday. Congratulations to everyone involved. Great job!
It has been no secret that I was working on providing Selenium 2 support for the Selenium IDE. To sync with the Selenium 2 release, I also committed the first cut of the Selenium 2 / WebDriver exporters in all four officially supported languages, viz., Java, Ruby, Python and CSharp. You should be able to get it from our CI server here (when it is accessible) or from the main download site (when Adam gets to releasing it).Â The main reason this is being released is to give you a chance to play with it and give us your feedback. It is probably well known by now that none of us who look after Selenium IDE actually use it. So your feedback is very valuable. The rest of this post gives you some details of what to expect.
The first paragraph very carefully mentions exporters. You already know that the format menu was marked experimental starting from Selenium IDE v1.0.11. This continues to be the case. If you really miss it, read how you can turn the format menu back on in Selenium IDE and what that means for you in my earlier blog post. I would really like to encourage you to try out the excellent export features available from the File menu.
Some people may find the names Selenium 2 and WebDriver a bit confusing. WebDriver is the new API that Selenium now offers. Selenium 2 is a generic name for the suite of tools that offer this WebDriver API and a bunch of other features. Read about it here.
The WebDriver API is more focused towards the programmer. It may take a while to get used to it. A one to one conversion from Selenese to WebDriver API is not possible in many cases. Many Selenese commands translate to multiple calls on the WebDriver API.
Some code may not have the expected result. Selenium 2 tools will try to emulate the real user as much as possible. This means that you will be faced with some situations where the old Selenese scripts that work will no longer work when converted to use the WebDriver API. A few examples: you can no longer click on elements that are not visible, and deselect single radio buttons or modify disabled form elements. Please keep this in mind when you convert your scripts.
The first cut of the WebDriver exporters support LIMITED number of commands. Some more commands would require some utility classes that I am working on and should be released next. The rest of the commands need to be prioritised and your polite feedback will be much appreciated in determining which commands will be chosen next. Please leave a comment on Issue 2003.
Stored variables are NOT supported yet, but will definitely come in soon. If you have used stored variables in your script, there will be no explicit errors thrown, but you may observe strange behaviour or code.
Some locator strategies/types are NOT supported either. The default (identifier) locator will NOT be supported. If you record new scripts, the identifier strategy will not be used, instead the id or the name will be used explicitly. I am thinking of creating a plugin to help convert the old scripts. Till then, you can manually update your script with either the id or the name strategy. The dom/document strategies will be supported later. It is likely that the UI locater strategy will not be supported.
The generated code is not optimised and will be very slow when executed. In general, it will make multiple WebDriver API calls. For example, if you have two click commands on the same element, the converted code will find the element twice and click it. If you wrote it by hand you will probably find the element first and store it in a variable then invoke the click on it twice. The main idea of the WebDriver exporters is to get you started and to educate you, so that you can optimise the generated code. I am exploring some ways to optimise the generated code, so there is hope for improvement in the future.
All the four new exporters offer you a new option – Show Selenese. You can turn this option on or off from the Options dialog. From the Options Dialog, go to the Formats tab and choose the exporter name. You should see the Show Selenese checkbox. If this option is on, the command being converted will be shown as a comment. This is an excellent way to understand how the conversion happens.
Finally, any errors encountered during the conversion like unsupported command, unsupported locators or others would be inserted as comments in the script as well. So be sure to read through the generated code.
I would also like to thank all the people who encouraged me to do this and helped me to make this possible. Thank you Simon Stewart, Jari Bakken, Jim Evans, Dave Hunt and others! I had great fun doing these converters. Hope you enjoy them. Let me know through the comments. I will post the list of supported commands soon.