Python or Java for Selenium?

Hello!

I apologise if this has been asked already, but I couldn’t find a similar thread.

I wonder which is better for selenium, Python or Java? Why?

I currently use python because the programmers at my company also use Python. However, I was browsing job ads to see what sort of skills employers are looking for and Java seemed to be the more popular choice.

Should I learn both?

1 Like

Java is indeed the most popular choice. But your best source of information are you developers.

I would say excel in Python and when you’re ready to pick up a second language go with Java

3 Likes

Go with your developers. Looks like your team has already decided to go with Python as a scripting language. Follow the below activities to get hands-on with Java for automation scripting.

-Answer Java related automation testing questions.
-Prepare Python and Java Selenium Cheat sheets.
-Publish automation testing blog posts using Java and Python scripting languages.
-Explore Page Object Libraries.
-Publish an automation testing utility which is useful for automation testing community in Maven central repository.

I have 13+ years experience in automation testing. I still setup automation testing frameworks using Python, Java, JavaScript, and C#. Nowadays, companies are looking for passionate automation testers. Don’t worry about the scripting languages.

Thanks,
Asiq Ahamed
Test Automation Architect at Codoid.

3 Likes

I am starting to follow the Python route myself, our tests are in Python already. I do some totally unconnected coding in Java though, but persevering with Python, even though most examples are Java.

There is no absolute winner or absolute truth but I tend to go with interpreted languages for tests because I think it is easier to move them around or change them.

In your case, I would say you want to follow what your team if you yourself are not feeling skilled enough to lead in other languages. I would go for Python and master that to a degree. After that, you can move to Java or other forms of testing. But always stick to one thing and don’t split your focus.

For future jobs and Selenium based testing - Java, Python or Ruby are all suitable with small differences in API, meaning even if you do a Python one, you will be able to score a job in Java Selenium.

2 Likes

Hello everyone

Thank you for your responses recently.

I ended up going for python and I used it for around 7 months, but now I am in a role using java.

Looks like I got both options in the end :slightly_smiling_face:

If I could choose… I would stick with python. I just prefer it as it is more straightforward to read/pick up.

4 Likes

The more languages you can at least read, the better. Sometimes boundaries are good, even Ruby might have it’s uses for all of us.

2 Likes

Per above, go with the developers. If you’re a Java shop, go with Java. Likewise for Python and C#. Once you’re familiar with Selenium, moving those skills to a different language shouldn’t be too much of a problem.

2 Likes

As we all know that Selenium is an open-source tool and it is used in software testing to test web-applications. If we talk about modern world now, Java and Python are two top programming languages in the market right because of their versatility, efficiency, and automation capabilities. Python is a very good programming language which is designed in a user-friendly manner with less syntax complications than any other programming languages.

But If we talk about using with Selenium, most of the software quality assurance services are using it with Java as it is more powerful and evolving. In terms of speed also, Java is much more faster than Python as it is a compiled language. Also, it takes very less time to execute a code.

Actually, there is not absolute answer to this question because some QA services prefers Selenium with Python because it is much more simpler and compact which uses indentation instead of braces on starting and ending the blocks.

At the end, Python have slight edge ahead of Java because Performance and trends also matters that which language runs fastest usually when it comes down to environment and how the code is written, used, and run not to mention the effects of the libraries and other external contributors.

Hope this information is helpful for you!!!

3 Likes

Very true “companies are looking for passionate automation testers. Don’t worry about the scripting languages.”

1 Like

I’d suggest giving higher priority to Python because your Devs use it. Moreover, it is far easier to do things with Python than Java. But, I’d suggest that you start learning at least the basics of Java when you have time.

PS -
Nothing wrong with Java, but here is an example of why I’d not recommend it for beginners.

Python : print(‘Hello’).

Java :
public class SomeName{
public static void main(String [] args){
System.out.println(“Hello”);
}
}

Umm… What is public, what is class ? What are void and main ? What is String [ ] args ? What is this System.out ? You could use JShell instead and simply type System.out.println(“Whatever”). But, you still wonder what is System.out ?

2 Likes