Are you starting out with test automation and thinking about Selenium? Or are you already automating tests with Selenium and feel bogged down by your programming language of choice? You’re not alone.
In my line of work I find myself answering the following questions quite frequently:
What programming language is best for Selenium automation?
I don’t know Java, can I still use Selenium WebDriver?
The answers might not be as clear as some might think. Sure the WebDriver bindings originate from Java, so this might sound like the first choice. But what if you don’t like working with Java or your work environment doesn’t play nice with Java.
The bindings are ported to quite a few programming languages and widely used, so you might think the answer to “what is the best?” is as simple as “Use whatever language you like best” (of the ported languages). But is this really true?
For me it was a no brainer to pick Java when I started out. I had some experience with Java and the information on Java-Selenium WebDriver is widely available.
Over the course of a couple test automation jobs I shifted away from the seemingly obvious answers and started thinking a bit further. The first incentive to reassess my answers came when I was forced to use a Python implementation of Selenium. I was not fluent in Python and I had a hard time enjoying my day to day work. I like finding “enemies” on my automation adventures, but not at the level I can’t start a fair battle. I felt bogged down by Python, it’s not for me.
Another insight came when I was using PHP (facebook php-webdriver) for an implementation. The client wanted to use Page Objects, which is fine, but I was used to Page Objects in Java. In Java you also get to use the Page Factory support package which makes using the Page Objects a fluent experience. In PHP Page Objects can be used, but the Page Factory is not available. There is an old implementation available, but I didn’t feel like maintaining a fork of this repository for this assignment. I’m not saying the PHP bindings are a bad port, but a port at best. There are no guarantees.
So what are my answers?
It depends. You need to take into account all variables which are involved and assign a relative value to each:
– What language is used to create the application under test?
– How proficient are you in the available languages?
– Do you wish to learn a new language?
– What are the time frames for the assignment?
– Are you working alone? Who will be working with your automation set up?
– Might you need a package which is not readily available?
This list is not complete for all assignments, but it should give an idea of what to think about.