DEV Community

Alan Liew
Alan Liew

Posted on • Edited on

2

Java 101 for software testing (Using fruits and vehicle as example)

Image description

I think many of you might have similar experience like me where I found myself struggle to understand of Java language.

There was a time I try to avoid myself from writing selenium testing script in Java, instead, I'm using Python to code.

And when I decided to learn and write selenium testing script using java but I'm devastated because of the endless of error seem to appear.. I can't understand the error log, the console log and etc. And I knew that was because lack of basic understanding of Java language.

Hence, I strongly recommend you to read this article before you write any selenium test scripts because you must build your foundation right before you write any scripts.

**

First, we ask WHY ? Why Java ?

**
✅ Java is a programming language that is commonly used in combination with the Selenium web automation tool.

✅ Selenium is a powerful tool for automating web browsers, and it can be used to automate a wide variety of web-based tasks.

✅ When used with Java, Selenium allows developers to write automated tests for web applications using the Java programming language.

✅ This can be useful for a variety of purposes, including functional testing, performance testing, and regression testing. Not only that, selenium has a number of libraries that can be used to extend its functionality or make it easier to use in certain situations.

**

Next, what is Java ?

**

✅ Java is an object-oriented programming (OOP) language.

You may wonder what is OOP means ? Don't freak out.

Let me make this simple for you. For example:
Fruits.

Image description

There are bananas, cherries, oranges, kiwis, grapes and apples in the picture.

✅ These are called Objects.
✅ And what are they categories as ? Fruits

Hence, Fruits is the Class and bananas, cherries, oranges, kiwis, grapes and apples is the Objects.

Is this sound simple ?

What about this picture ?

Image description

We can see trucks , ambulance, bus and car.

And what are they ? Vehicles

So we know Vehicles is Class and trucks , ambulance , bus and car is an Object.

Now, what is the color of the car ? Blue

Blue is the attribute of the Car.

How do we operate the vehicles ? Drive

Drive is the method

We can conclude 4 things from this , we know the class (vehicles), the object (car, bus, trucks, ambulance), attributes (blue, 4 tires , etc) and method (drive).


public class Vehicle { <- this is class = vehicles

String carBrand = honda; <- this is objects and attributes
Int numOfTires = 4; <- this is objects and attributes

void Drive(){ <- this is drive method
System.out.print("Car is driving");
}

public static void main(String[]args){

Car myCar = new Car();

myCar.drive();


This is just a simple java program to show you how the java structure it is. It's OK not to understand everything in the first place. Just get along with me , and I can assure you will have sufficient java knowledge to write your first selenium script with Java.

❤️

Related Articles:
1. Cloud Computing , let’s talk about it [Part 2]
2. AWS ! the terms you must know 🤫
3. ISTQB 🧙🏻‍♀️The software testing Myth, do you need that?
4. Why Software Testing is necessary in the first place?👀

❤️

Connect with me in Linkedin !

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (1)

Collapse
 
rickdelpo1 profile image
Rick Delpo

For beginners I recommend starting with JDBC and connect to some Data. This way u have 2 skills, Java and SQL.

check out my basic tutorials at
howtolearnjava.com

my other site shows u how to migrate from SQL to NoSQL in Javascript
javasqlweb.org

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay