If you use Selenium, then you must already know about locators. The locators in Selenium are usually the target part of your Selenese commands which identifies the elements on the web page that you want to interact with. This post is not about locators, but about the locators builders.
I introduced the Locator Builders in Selenium IDE through some of my earlier posts. They are components that build the locators for you when you are recording in Selenium IDE. You can take a quick look at Creating CSS Locator Builders for Selenium IDE and The Selenium-IDE 1.x plugin API (Part 12) â€“ Adding Locator Builders. Selenium IDE has several locator builders bundled with it, including the most recent one for building CSS locators. SeeÂ Welcome Selenium IDE 1.0.11 (with Firefox 4 support) and A Quick Introduction to CSS Locators in Selenium. Selenium IDE plug-ins can also add new Locator Builders.
The order of the Locator Builders can be very important. The result of the first Locator Builder is added to your recorded Selenese command. You have the ability to choose another locator from the target drop down list until you close the recorded test case. When some people get stated with Selenium IDE, posts like Learn Alternate Locators Using Selenium IDE open a whole new world. If you need a particular locator type for your web application or a part of your web application, you have the option of manually changing it from each recorded command. It is simply more efficient to change the order of the locator builders as you need.
At the first look, the management of Locator Builders lacks a few features, but there was a concious decision for most of them. Firstly, it is not possible to remove a locator builder. I decided that deleting a locator builder was generally a bad idea. Instead of deleting a Locator Builder, it is better to change the order and move it down. This way, it is out of the way and you can still have it back in case you change your mind some day. Secondly, once any Selenium IDE plug-in provides a Locator Builder, its order will be remembered even if you remove the plug-in. I made the decision to retain the removed locator builder because it is quite nice to reinstall the plug-in and have the old order back. I have come across some cases when you need to uninstall some plug-in and install it again. Lastly, there is no way to enable or disable a Locator Builder. Again, I decided against having this feature as changing the order is usually sufficient.
There would be some more enhancements coming up in the future. I am planning to add a way to identify the Locator Builders which are not currently available. Another enhancement would be to give a short description and some examples of the kind of locators that are built by the locator builder. Let me know if you can think of anything else.
In the past some people have mentioned to me that they enjoy reading about my experiences as I develop these features. I found working on this enhancement quite nice. I recently started down the Functional Programming road and I used some of these concepts in the code. It was quite satisfying to see the amount of code I had to write shrink down. Most of the time, I wrote two version of the same piece of code and kept the one I thought was better. For people who have no exposure to functional programming might initially find some parts of the code a bit hard to read, but I hope I have put in the right balance between readability and ease of programming. The major part of my time was spent in deciphering how to use drag and drop in a Listbox to rearrange the items. I think I have done a pretty good job and I have a reusable module that can save some people some time. I hope to write a blog post on it and make it available as soon as I find some time.
Don’t hesitate to leave a comment about what you think. I always love hearing from you.