6

Should I learn Python or Java to get into test automation?

I'm new to programming. Please share your thoughts or links to any useful information.

  • 3
    Do you work with devs - if so, what do they use? Why not Ruby? Or Perl? – Phil Kirkham Feb 5 '14 at 4:26
  • I want to learn selenium webdriver, but I do not know how to code. I'm a manual tester who wants to get into automation. – pythonjava Feb 5 '14 at 6:41
  • 2
    See also sqa.stackexchange.com/questions/1674/… – user246 Feb 5 '14 at 15:36
  • This is so close to the question @user246 pointed out (which has a lot of good answers, and is better worded) that I'd be inclined to close this as a duplicate if it didn't already have some good responses. What do you think? – testerab Feb 8 '14 at 14:27
  • Let's discuss that in Meta. – user246 Feb 8 '14 at 14:29

16 Answers 16

5

Since you are looking into Selenium (as a test framework) start with Java, because Googling on "Selenium/Webdriver issue description" will often result in Java examples that you can re-use. There is just more people doing Selenium with Java then Python. Also Selenium it-self is mainly written in Java.

For a project I would learn the language the application (under test) is written in. As a tester your are often not a hardcore programmer, thus if you need assistance with the test automation its ideal if the team can help you in a language they use on a daily basis and have the most experience with. This will also increase the adoption and extension of your tests by the developers, they will have to maintain/extend the tests in the end probably.

If your learning preference is from books I suggest "Thinking in Java" each chapter has great programming challenges to make sure you understand and can apply the theory. Also it explains everything in great detail.

Update: Also Java looks a lot C++ and thus also C#. If you look at the most popular languages the C derivatives are most popular. Learning Java will make it easier to switch to other languages.

2

It is not compulsory to learn Python or Java for Automation but it would be better to know Java concepts(or python concept if using python in Automation) and basic fundamental of language.

If you need to know and understand core of framework like selenium or testNG then you should have good knowledge of Programming language knowledge.

2

I'm a fan of the Udacity classes: Computer Science 101: uses (and teaches) Python basic CS concepts, while building a search engine: https://www.udacity.com/course/cs101

Software Testing: Teaches testing, by writing Python test code https://www.udacity.com/course/cs258

  • While these are useful resources, they don't really answer the original question. (Admittedly the original question does ask for links, but what's your view on the main question?) – testerab Feb 8 '14 at 14:23
2

Nowadays, irrespective of being a developer or tester we all need to know a development language and my advice will be: either Java or Python both are doing equally good; but learning python is easier, number of lines of code in python is also very less for given functionality, maintainability of code is easier and structuring is also very simple compared to Java.

However resource availability (namely libraries, tools, end to end integration support) for Java is a little higher as Java is widely used.

Nevertheless there a is big turnaround in Python from past 4-5yrs and it's taking over the software industry and future seems to be Python as it's evidently introduced even at schooling level (in India & rest of the world I am not that sure though) and there exists no Java in there and C++ is optional. Lots of Python utilities are available to fulfill the needs of most of the technical sectors.

From jobs point of view of today there are more jobs for Selenium with Java than Selenium with Python.

Java is a really good language too, but it takes more to learn Java than Python.

Now how long you want to code is one of the important decision you need to make!

  • 1
    Since MIT introduced Python as first programming language for both Comp-Sci and non-COmpSci tracks few years ago, many universities in USA are also switching from Java to Python as first language. – Peter M. Dec 11 '17 at 15:21
1

Personally I would have to recommend that you learn Ruby. Most of the BDD automation tools like Cucumber and RSpec are coming from the Ruby community and it offers a wealth of test automaton tools available.

As you are new to programming, I highly recommend that you head over to code academy and do their free online ruby training.

I would also recommend that you grab a copy of the Cucumber book and start working through it.

1

It depends from software development branch you want to come. But I suggest you to learn Java because this is one of the most popular language at nowadays (http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html). If you will learn Java you shall develop tests for Desktop, Web and Android. Also I suggest you to learn Python, Shell, Javascript - they are easy to learn and a lot of application may to use.

  • Maybe you could give some more information on factors that would influence the decision? That would make your answer more useful. – Kate Paulk Mar 11 '14 at 11:03
1

Start with Python, without any doubt.

Python can make huge difference for beginner. I remember that child of one of my friend spent few weeks in a summer camp learning Java or C++, and got really confused and not sure anymore he wants to study computers. I started Python interpreter and shown him how easy things can be, and I remember the smile on his face which explained everything.

Python is much easier to start with, for several reasons:

  • dynamic typing: if type of your variable is OK (which usually is), things "just work"). In Java, types are much more complicated and messy.
  • interpreter, which allows you to program "one line of code at a time" and try expressions without the need to write small program to test concepts, like you have to do in Java
  • huge library of convenient functions, called "batteries included"
  • debugger which allows you trivially examine you objects and which methods they have. So instead of spending hours reading docs, you can experiment in your code
  • lots of free online resources for learning the language, including excellent online courses, some even using "python in your browser" approach, so yo don't even need to install Python
  • Python is first language designed to be read by human as first priority
  • Python code can be procedural (easiest to start with and comprehend), object-oriented or functional. You can start with simple procedures, and using existing Python objects will satisfy your needs for long time. In Java, objects are the only way.

Java objects are often they are confusing: in example, there are multiple integer types: Integer (which is object), and int, which is not. I've seen the confusion it caused to beginners first-hand, and few more, with different precision (how many digits they can hold). Using wrong type in Java will cause compile-time or worse runtime error. Python has just one integer type, and will convert internally to whatever precision you need. Same with array size: If your data increased and will not fit, Java will have runtime error, Python will double the array size.

Python is excellent also for many tasks for which Java is not a good fit: small little programs to manipulate files, parse and analyze text files like log files, to automate system administration tasks.

Python was designed for people who are not experts in computer science/engineering, and need a language which works hard to help them to solve their problems.

Disclaimer: Obviously, there is no silver bullet. Even in Python, if you use wrong type, you will get runtime error.

  • I'm going to disagree here. Python spoils new developers. Python introduces functionality and standards that are not enforced by most languages. – Jeremy Kowalski Dec 11 '17 at 17:53
  • @JeremyKowalski - I am going to agree with you. Yes, Python shows how other languages are deficient and are forcing the programmer to work too hard, instead of just solving the problems and shut up. :-) That's why I prefer Python, but I admit I do know what is going behind the scenes, and for Python users who do not, using other languages might be a bit confusing until they learn the ropes. – Peter M. Dec 11 '17 at 19:32
0

For Automation testing you have to learn programming language. Sure, first steps may be to do with play-and-records tools (like Selenium IDE or CodedUI)

But for solid framework system you should write heap code, use patterns, debaggs and storage code in CVS system (git or svn).

My opinion, the first language must be same which your developers use. They can help you and get good tips hot to use code.

For first steps in dev follow next links:

WebDriver docs

Codeacademy where you can do first steps with python, ruby and more

Webdrives patterns

Git

Good luck!

0

If you are going to learn it on your own (in case your company does not buy an expensive automation tool that you MUST work with) I advise you to start with basic programming language courses, preferably the same as your devs use, buy a book on it and start from the beginning

After that look at webdriver documentation and start building a framework (a set of functions that you use regularly in order to save time and make your code readable and easy to debug). I think is better to use "C# + Visual Studio + Git" or "Java + Eclipse + Git", these are the ones I know better, if your devs use python or ruby they can help you with that.

Anyway, just speaking from my own experience, no fundamental knowledge here...

0

The answer is yes and no.

You should have knowledge about programming to be able to adopt the situation you are in. When it is needed you should be able to learn the particular language to write automated tests. For example, selenium can be used with many languages because there are little differences in its API. So that, the point of the "pick up new stuff" situation is the programming language itself and the technology (if you are in java environment you should know what the difference between pure java and JEE) not the selenium itself.

Here is my situation. When I started working in IT I only knew php. Later I learned java and I wrote a lot of automated UI tests using Selenium in java. Later, I changed my job and I had to learn how to do this using c#. Now my girlfriend has to learn how to do the same using Ruby and she asked me to help, so that I had to learn Ruby. The more time I go through this "pick up new stuff" process the easier to pick up the necessary knowledge to do my job.

Sometimes my job was only testing not to write automated tests because it was the developers' tasks as well. So, as you can see to create automated tests it is not necessary to have programming skills because, sometimes, test automation is part of the development tasks. However, if you are able to take part not only test creation (BVA, QP, etc.) but also test automation you will be respected not only because your knowledge, but also your attitude.

The backside of the whole is that, my knowledge is superficial ( I dare say that my skills would be enough to be an experienced junior programmer, however my whole IT experience would be enough to be a senior due to the stuff I have seen so far), so I have to spend time to make it stronger. But, as a tester I'm a respected because I have skills and I learn fast.

0

Below is some documentation for Selenium as for each particular language it accepts:

These should help you get a start with Selenium in each language.

Here is a detailed comparison between Java and Python. It explains how Python is typically more concise than Java, which is very true. With Python you are likely to end up with far less code. This can be a huge benefit and make it far easier to learn Python.


Personal Preference

If I had to choose between Python or Java I would likely choose Java. It just has a better future and is more likely to be what is being used by the system than Python. Also it is, in my opinion, a lot easier to learn.

If I had to choose between all languages, I would likely suggest Perl for software testing. A lot of testing has to do with verification and strings, Perl is likely the best languages for this. Also, get started with regular expression as quickly as possible, it will pay off big time. And since Regular Expression's basics transfers throughout the majority of the programming languages it will give you a huge advantage over a lot of the other testers in the market.

Ultimately it depends on what your attempting to accomplish. Do you want to be great at your job or do you want an impressive resume? I can list 9 programming languages on my resume since I dabble in a lot of them for different situations. If I need to do a lot of String parsing, I choose Perl. If I need a quick script, Python. Something more advanced, Java. And since my company seems to love ASP for all of their QA stuff, when I need to update our internal QA sites, it's usually ASP.Net.

0

I would suggest Python as it is very easy to learn. If you are going to use Selenium webdriver then you can go through the documentation and sample code at http://docs.seleniumhq.org/

0

It all depends on your project requirements and tools to be used. To start with automation testing you don't necessarily need to master any language upfront.

Of course, knowing a programming language what your tool is going to be used or designed is helpful. It's better to start with understanding the concepts and framework for automation.

For selenium webdriver,as all said, one can start with basic Java skills. For the question of Python vs Java, a few factors play a role

  1. Type of project
  2. Automation Requirements
  3. Type of Tool
  4. Scripting language required to operate the tool.
  5. Lately the type of framework

On the other hand, it's always complementing to have scripting skills. For QA, Perl, Python, VBScripting etc are a few of the useful skills.

0

Do not tie yourself to a language. Learn the fundamentals of good programming design. Learn when to use a conditional loop, or when to make a function of inline code.

I never know what language I am going to be expected to work in, but I know the fundamentals of OOP and test design. Start with pseudo coding and just work out the "How" you will accomplish the task. Answering the question of "What" language to implement or what tool to select can come later.

0

Though it's not mandatory but as a new programmer, Python and Ruby are the better choices to start. From my personal experiences, their learning curves are steeper and very interesting which will make your automation expedition really enjoyable.

0

It is very important in test automation to start with your language means you comfort zone and my advice will be: either Java or Python both are doing equally good, but learning python is easier than Java, number of lines of code in python is also very less for given functionality as compared to java.

However, resource availability (namely libraries, tools and end to end integration support) for Java is a little higher, as Java is widely used.

Nevertheless there a is big turnaround in Python from past 4-5 yrs and it's taking over the software industry and future seems to be Python as it's evidently introduced even at schooling level (in India & rest of the world I am not that sure though) and there exists no Java in there and C++ is optional. Lots of Python utilities are available to fulfill the needs of most of the technology sectors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.