Variables, data types, and operators are the foundation of every automation script you will ever write. They let you store and reuse information like URLs and usernames, handle different kinds of data, and compare an actual result against the one you expected. Get comfortable with these three ideas and you can write scripts that adapt to real test cases instead of doing the same thing every time. This is the bedrock everything else in the course sits on, so take it slowly.
Variables: labeled boxes for your data
A variable is a labeled storage box. You put a value in it, read it back later, and change it whenever you need to. In JavaScript you usually create one with the let keyword.
let username = "qa_tester";
let password = "test123";Here username is the label and "qa_tester" is the value stored inside it. A few naming rules to keep you out of trouble: a name must start with a letter, an underscore, or a dollar sign, never a number; it cannot contain spaces; and when a name has several words, write it in camelCase like expectedResult. Pick names that describe the value. loginUrl tells you far more than x ever will.
You can also change what a variable holds after you create it.
let testStatus = "pending";
testStatus = "passed";
console.log(testStatus); // passedIn automation that might be a test that started as "pending" and became "passed" once it ran.
Data types: the kind of value stored
Variables can hold different types of data, and that matters because some actions only work with certain types. Strings are text, written inside quotes, and you will use them for URLs, names, and error messages.
let pageTitle = "Login Page";Numbers need no quotes and cover quantities, prices, and IDs. Booleans hold only true or false, which is perfect for tracking a pass/fail condition or a login state.
let itemCount = 5;
let price = 19.99;
let isLoggedIn = true;
let hasError = false;Collections: arrays and objects
Two more types let you group values together instead of scattering them across many variables. An array is an ordered list, ideal for running the same steps with different inputs.
let testCases = ["login", "checkout", "search"];An object groups related values under named keys, which keeps connected data in one place.
let user = {
username: "qa_tester",
password: "test123",
role: "admin"
};You will lean on both of these constantly once you start feeding real test data into your scripts.
Operators: acting on your data
Operators let you combine, compare, and manipulate values. Math operators handle the arithmetic you need when testing totals or prices.
let total = 2 + 3; // addition
let difference = 5 - 2; // subtraction
let product = 4 * 3; // multiplication
let quotient = 10 / 2; // division
let remainder = 10 % 3; // remainder (modulus)Comparison operators check whether two values match or follow a relationship, and they are the heart of every assertion you will write.
let expected = "Login Page";
let actual = "Login Page";
console.log(expected === actual); // true
console.log(5 > 3); // true
console.log(10 <= 5); // falseLogical operators let you combine several conditions before deciding pass or fail. && needs both sides to be true, || needs at least one, and ! flips a value to its opposite.
let isLoggedIn = true;
let isAdmin = false;
console.log(isLoggedIn && isAdmin); // false (both must be true)
console.log(isLoggedIn || isAdmin); // true (at least one)
console.log(!isLoggedIn); // false (the opposite)Putting it all together
Here is a tiny login test scenario that uses every idea from this lesson. Notice how the final comparison decides whether the test passed.
let loginUrl = "https://example.com/login";
let username = "qa_tester";
let password = "test123";
let expectedTitle = "Dashboard";
console.log("Navigating to " + loginUrl);
console.log("Entering username: " + username);
console.log("Entering password: " + password);
// Simulated result of the login
let actualTitle = "Dashboard";
// Assertion
if (actualTitle === expectedTitle) {
console.log("Test Passed");
} else {
console.log("Test Failed");
}The same idea in Python
Many QA teams automate in Python (pytest, Playwright for Python, the requests library), so it pays to read the same fundamentals in both languages. The ideas are identical; only the syntax shifts. There is no let or const, you just assign a name; comments start with #; the console call is print(); and the convention for multi-word names is snake_case like expected_result rather than camelCase.
username = "qa_tester"
password = "test123"
# Data types: strings, numbers, booleans
page_title = "Login Page" # str
item_count = 5 # int
price = 19.99 # float
is_logged_in = True # bool (note the capital T)
# Collections: a list is an array, a dict is an object
test_cases = ["login", "checkout", "search"]
user = {"username": "qa_tester", "password": "test123", "role": "admin"}Operators read almost the same, with two differences worth memorizing: Python uses and, or, and not instead of &&, ||, and !, and equality is a plain == rather than JavaScript's strict ===.
expected = "Login Page"
actual = "Login Page"
print(expected == actual) # True
print(5 > 3) # True
is_logged_in = True
is_admin = False
print(is_logged_in and is_admin) # False (both must be true)
print(is_logged_in or is_admin) # True (at least one)
print(not is_logged_in) # False (the opposite)Here is the same login assertion from above, written in Python. Notice the colon and indentation take the place of curly braces.
login_url = "https://example.com/login"
expected_title = "Dashboard"
actual_title = "Dashboard" # simulated result of the login
if actual_title == expected_title:
print("Test Passed")
else:
print("Test Failed")Read the two versions side by side until the mapping feels obvious. Every concept in this lesson exists in both languages, so once you own the idea you can switch syntax on demand.
Practice and takeaway
Open a file called fundamentals_practice.js and create variables for your name (a string), your age (a number), whether you are learning automation (a boolean), a list of your favorite automation tools (an array), and an object holding a username and password. Print each one with console.log(). Then use a comparison operator to check whether your age is greater than 18, and a logical operator to check whether your age is greater than 18 and you are learning automation. For extra credit, redo the whole exercise in a fundamentals_practice.py file so the two languages start to feel interchangeable.
The takeaway: variables name your data, data types describe its shape, and operators let you compare and combine it. Every assertion you ever write is just these three ideas working together, so practice them until they feel automatic.