Is Java needed for Selenium?

Hello all Testers,

For some few day I am thinking about Selenium and also wants to learn some automation. But, in every tutorial website I encountered with Java as prerequisite. So, is it really necessary to learn java or any other programming language first to get hands in Automation?

Hi there,

Java is not a requirement, and theoretically you do not need a programming language but if you want to get into automation you really need to start learning a language. I was part of a group creating the curriculum for a technical tester education and there we chose to teach Python, so I would suggest to learn Python. Not because it is so great with selenium but since it is applicable in a lot of test automation scenarios. https://www.seleniumhq.org/about/platforms.jsp

Other factors I generally take account for is what language is the product you are working with written in. If you can learn the same you typically will be surrounded by a lot of people that can help you on the way. And you get the added benefit of understanding more of the code.

For reference for selecting a language to learn. http://carlcheo.com/startcoding

1 Like

One of the main reasons test automation fails is the effort to maintain the test automation suite becomes too expensive (time, money, expertise, etc.)

In theory, you can use HTML tables and automation plugins to create your test automation suite but my experience has been modern websites are rather complex.

There are two options for this. One is to hire a lot of QA automators and have the software developers put things in the application to make it easier to test and for the test suite to be easier to maintain. The other is to apply software development techniques to make the test automation suite easier to maintain.

If you are using Selenium without programming knowledge and depending on the application developers to make the application more testable you might as well just use an automation tool like HP Quality Center. It will give you a more complete package and handled a variety of other things that core Selenium won’t do for you.

I have seen teams start with depending on the application developers to make the application more testable or reduce how much you automate with Selenium but with the long term goal of moving to option Two. So you start with core Selenium but expect to learn programming techniques to make the test suite more maintainable. In this case, some tests don’t need much to keep them maintainable. As you get into tests which are a little harder to write without some programming knowledge than the Selenium automators are expected to learn programming.

Of course the ideal use of Selenium is to start with programming knowledge and not be dependent on the application team (or not as much) to keep the application more testable and the test suite easier to maintain.

The programming language controls the Selenium client. The client calls the Selenium APIs to control the browser. Each language implements a client. So the Java client will be developed separately from the Python client. This means there are subtle differences between the Java and Python implementations of Selenium. There are other languages as well. I have found that Java has been around longer, the tools (like IDEs) and language are more stable. So learning Java tends to be ‘safer’. But really, if I work in a company using Ruby for development, I might just use the Ruby implementation of Selenium client. Especially as a consultant. I tend to create something then leave the client to maintain it. So I pick a language they are comfortable with.

Now it is important to understand that you aren’t going to be using frameworks, plugins and extensions that a modern Java developer uses in order to create and maintain a Selenium framework. Things like Spring, Lombok, Flyway, etc. won’t be necessary for Selenium development. Really, you want to keep it simple. So the programming knowledge you’ll need for an intro to Java is all that is really necessary.

Darrell

2 Likes

Thanks @Darrell for giving such a detailed explanation.

The selenium libraries are available on several languages, but I share you experience of finding many online tutorials are based on java.

Check out Udemy which has many courses for about $10 teaching selenium with C#, Python etc if you think java is heavy weight.

However, commercially my experience has been that most Enterprises using Selenium usually are Java or .Net houses and it makes so much sense to write your tests in the same languages as your primary Devs. If this is your goal, I’m afraid Java or C# is probably on the cards at some point.

I would agree with what Darell and Ola have written.

First you need to decide what you are automating, if it is only web based applications, then the best option in the market is Selenium. There are methods/processes you can use to do this, called frameworks, like cucumber, gauge, etc. which can provide the structure and a BDD type of readable language for the other users like the BA and Dev.

If you have some desktop based applications, then better to go with tools like Tricentis Tosca, Microfocus UFT (HP QTP), TestComplete, etc.

Both these approaches do require that you have some basic language understanding. With Selenium, you get a lot of flexibility in using the language of choice. I would say that go with something which your team is working with (like mentioned above, use Ruby, Python, Java, C#, etc.), depending on the comfort level for yourself and your team also, so that maintainability is not an issue later. That said, if it is a dedicated QA team, then decide among the team as to the comfort level of the majority and then work on that language.

Automation with tools like Tricentis Tosca (C#) or Microfocus UFT (VB Script), also requires a level of language grasp, to create complex structures which are common in web applications. Selenium also requires that you write the code to recognize objects and control them.

To summarize, I would say, it is best to learn a language for Automation to be a success and also to provide something which is maintainable. You can go to sites like stackoverflow.com to get snippets of the code that you can put in your test automation, but it would create an un-maintainable piece of work, which you yourself would not be proud of or be able to maintain for long.

Sites like Pluralsight and eDX are good starting points. And there is a wealth of information available on the ministryoftesting.com itself.