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.
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.
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.
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.
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.
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 ?
I am using Python, because loads of test tooling has Python bindings. But since the app you are testing will often be written in “javascript”, React/Ajax/Angular and other JS frameworks, you will find that injecting code snippets and reading and understanding JS “minification/obfuscation” and so on in browser is useful.
For example getlog(“browser”) selenium calls only work well in chrome, and not all chromium based browser drivers work the same, and this little JS oneliner hack helps to pull console.log traces from the app
Nice followup. I think the real takeaway here is that the language itself doesn’t matter. With the nature of the software industry and work these days, most of us are going to bounce around a bit, and that’s going to require working with different tech stacks. Become proficient with a language, learn some core programming concepts, but be open and flexible to having to apply those concepts to a language/tech stack that you might not be familiar with.