Part 3: Java Fundamentals for Test Automation
Since Appium tests are often written in Java, it’s important to understand some basic Java concepts. Don’t worry—we’ll cover only the essentials so you can start automating quickly


1. Variables & Data Types
- Variables store data like numbers or text.
- Common data types:
- int — stores whole numbers (e.g., 10)
- double — stores decimal numbers (e.g., 5.5)
- boolean — true or false
- String — stores text (e.g., “Hello”)
Example:
int age = 25;
double price = 19.99;
boolean isEnabled = true;
String name = "Appium";
2. Methods and Functions
- A method is a block of code that performs a task.
- You can call methods to reuse code.
Example:
public void printName() {
System.out.println("Appium Tutorial");
}
To call it: printName();
3. Classes & Objects
- A class is like a blueprint for creating objects.
- An object is an instance of a class.Example:
Example:
public class Car {
String color;
public void drive() {
System.out.println("Car is driving");
}
}
// Creating an object
Car myCar = new Car();
myCar.color = "Red";
myCar.drive();
4. Conditionals (if/else)
- Used to make decisions in code.
Example:
int score = 80;
if(score > 70) {
System.out.println("Test Passed");
} else {
System.out.println("Test Failed");
}
5. Loops (for, while)
- Run the same block of code multiple times.
For loop example:
for(int i = 0; i < 5; i++) {
System.out.println("Iteration: " + i);
}
While loop example:
int i = 0;
while(i < 5) {
System.out.println("Iteration: " + i);
i++;
}
6. Arrays & Lists
- Store multiple values in one variable.
Array example:
int[] numbers = {1, 2, 3, 4};
List example:
import java.util.ArrayList;
ArrayList names = new ArrayList();
names.add("Appium");
names.add("Selenium");
7. Exception Handling (try-catch)
- Handle errors
Example:
try {
int result = 10 / 0;
} catch(ArithmeticException e) {
System.out.println("Cannot divide by zero");
}
8. Inheritance and OOP Basics
- Inheritance lets a class reuse code from another class.
Example:
class Animal {
void eat() {
System.out.println("Eating...");
}
}
class Dog extends Animal {
void bark() {
System.out.println("Barking...");
}
}
Dog d = new Dog();
d.eat(); // Inherited method
d.bark();
9. Packages and File Organization
- Packages group related classes together.
- Keep your project organized by separating different parts into packages.
Example:
package com.appium.tests;
public class SampleTest {
// test code here
}
Summary:
Concept
Why it matters for Appium tests
Variables
Store data like element IDs, text, etc.
Methods
Organize reusable code blocks
Classes & Objects
Structure your tests and page objects
Conditionals
Handle test verification logic
Loops
Run repetitive actions, like clicking multiple buttons
Arrays & Lists
Manage groups of test data
Exception Handling
Handle errors without crashing tests
Inheritance
Reuse and extend test functionalities
Packages
Keep test code clean and maintainable
Hands-on Practice with Eclipse
Let’s get our hands dirty by writing and running basic Java code using Eclipse IDE, which will be your main tool while building your Appium automation framework.
Step 1: Install Eclipse (If You Haven’t Yet)
- Go to https://www.eclipse.org/downloads/
- Download Eclipse IDE for Java Developers
- Install and launch Eclipse
- Select a workspace folder (your working directory)


Step 2: Create a New Java Project
- Open Eclipse
- Go to File → New → Java Project
- Give your project a name (e.g., JavaBasicsAppium)
- Click Finish
Step 3: Create a Java Class
- Right-click on the src folder inside your new project
- Click New → Class
- Give the class a name (e.g., PracticeBasics)
- Check the box for public static void main(String[] args)
- Click Finish
Step 4: Write Some Simple Java Code
Paste this code inside the class:
public class PracticeBasics {
public static void main(String[] args) {
System.out.println("Hello, Appium World!");
int a = 10;
int b = 20;
int sum = a + b;
System.out.println("The sum is: " + sum);
}
}
Step 5: Run the Program
- Right-click on the file → Run As → Java Application
- You should see the output in the Console tab at the bottom:
Hello, Appium World!
The sum is: 30
What You Just Practiced:
- Creating a Java project and class in Eclipse
- Writing and running basic Java code
- Using System.out.println() and variables
Next Steps:
- Practice writing methods, loops, and conditions
- Create a utility class and call methods from main()
- Build comfort before moving into real Appium script../
Building complex IoT systems?
Accelerate testing and deployment with our QEMU-integrated toolchain expertise.
Mastering Appium: A Complete Beginner-to-Expert Mobile Automation Guide

Part 1: Introduction to Mobile Automation and Appium

Part 2: Appium Architecture, Tools Setup & How Test Code Connects to Devices
