Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (41.4k points)

Which programming language is better for writing Selenium webdriver scripts, Python or Java? Which is widely used and why?

1 Answer

0 votes
by (106k points)

According to my experience with using Selenium with both Python and Java for automating web-based interactions for complete end to end automation.

Let’s see Python first:-

Pros of Python:-

  1. Python is very easy to code/read. Hence, easy to debug later on

  2. It is comparatively faster to code and test which makes implementing new codes quickly.

  3. You can write and test each line of code in IDLE and hence see where any error/undesirable/completely new actions are occurring. I think this is the single best thing as compared to Java.

Cons of Python:-

  1. For the purpose of creating a deployable file like an executable file or an archive file which can be ported to different systems is not good. As the client needs to have Python, Selenium for your script to work.

Now let’s see Java:-

Pros of Java:-

  1. Mostly Selenium is supposed to have a better integration with Java as the Selenium RC is coded in Java.

  2. If you are using an IDE like Eclipse, creating new projects become a breeze as compared to Python's IDLE. I have not yet found an IDE like Eclipse for Python.

  3. For creating an archive executable file like JAR file for deployment is what will make it the language of choice if used for a corporate style development usage.

Cons of Java:-

  1. A number of lines of code are high as opposed to Java which can make it cumbersome.

  2. You have to run the entire code rather than using it line by line in Python which in many cases may reflect to be quite bothersome and non-enlightening.

If you are looking to have a certificate you must have a look at the Selenium Training Course. If you are interested in reading you must have a look at the following Selenium Tutorial. Here is the video through which I came to know all these things.


Browse Categories