Practical labs from the "Software Testing Automation" course
Stack: JavaScript · Jest · Selenium WebDriver · Cucumber (BDD) · Pactum
| Lab | Topic | Tools | Target |
|---|---|---|---|
| Lab 4 | Unit Testing & Mocking | Jest | Custom JS classes |
| Lab 5 | Browser Automation — Basics | Selenium WebDriver | Wikipedia |
| Lab 6 | Browser Automation — Page Testing | Selenium WebDriver | automationexercise.com |
| Lab 7 | Browser Automation — Real Site | Selenium WebDriver | hotline.ua |
| Lab 8 | BDD with Cucumber & Gherkin | Cucumber · Selenium | automationexercise.com |
| Lab 9 | API Testing | Jest · Pactum | Multiple public APIs |
Framework: Jest
Testing custom JavaScript classes and async functions with mocks and dependency injection.
What's tested:
UserService— greeting with mockedgetFullNamedependencyasyncHello,computeValue,asyncError— async/await patternsApiClient— mockedfetch()callsApiHelper— invalid data validationcalculateFinalPrice— order pricing with discount service injectionOrderProcessor— async currency conversion with mocks
// Mocking a dependency
const mockGetFullName = jest.fn().mockReturnValue('John Doe');
const service = new UserService(mockGetFullName);
expect(service.greet()).toBe('HELLO, JOHN DOE!');Framework: Selenium WebDriver · Jest · Chrome Target: wikipedia.org
End-to-end browser tests using locators: ID, CSS, XPath, LinkText.
Test cases:
- ✅ Search box and logo are present on the homepage
- ✅ Search for "Selenium" navigates to the correct article
- ✅ Article heading verified via XPath (
//h1[@id="firstHeading"]) - ✅ All navigation links start with
https://en.wikipedia.org - ✅ Click "Oxygen" link, wait for navigation, check CSS color of heading
const searchBox = await driver.findElement(By.id('searchInput'));
await searchBox.sendKeys('Selenium');
await searchBox.submit();
await driver.wait(until.titleContains('Selenium'), 5000);Framework: Selenium WebDriver · Jest · Chrome Target: automationexercise.com
Testing core UI elements of a practice e-commerce site. 9 test cases across multiple test files.
Test cases (mainPage.test.js + others):
- ✅ Top navigation menu (
ul.nav.navbar-nav) is present - ✅ Logo
altattribute equals"Website for automation practice" - ✅ "Signup / Login" button contains text "Signup"
- ✅ + 6 additional test cases across other test files
const logo = await driver.findElement(
By.css('img[alt="Website for automation practice"]')
);
expect(await logo.getAttribute('alt')).toBe('Website for automation practice');Framework: Selenium WebDriver · Jest · Chrome Target: hotline.ua
Testing search functionality on a real Ukrainian e-commerce platform with dynamic content and extended timeouts.
Test files:
search.test.js— search field visibility and result loading after querybuyButton.test.js— search for "ноутбук", verify.list-itemresults appear
const searchBox = await driver.wait(
until.elementLocated(By.css('#autosuggest input[type=text]')), 20000
);
await searchBox.sendKeys('ноутбук', '\n');
const results = await driver.wait(
until.elementLocated(By.css('.list-item')), 20000
);
expect(results).toBeTruthy();Framework: Cucumber · Selenium WebDriver · Chrome Target: automationexercise.com
Behavior-Driven Development using .feature files with Given/When/Then syntax and step definitions in JavaScript.
Scenarios (testcases.feature):
| Scenario | Description |
|---|---|
| TC02 | Login with correct email and password |
| TC04 | Register new user with full account details form |
| TC05 | Register with existing email → error message |
| TC06 | Navigate to Contact Us page |
Feature file example:
Scenario: TC04 Register User
Given I open the browser
When I navigate to the homepage
And I click on Signup Login
And I enter name "LogoutUser" and email "unique"
And I click Signup button
Then I should see "ENTER ACCOUNT INFORMATION"
When I fill account details
And I click Create Account button
Then I should see "ACCOUNT CREATED!"
And I close the browserFramework: Jest · Pactum Target: Multiple public REST APIs
Testing 4 public APIs: status codes, response structure, data types, and parametrized tests.
Test suites:
| Suite | API | Tests |
|---|---|---|
| Currency API | currency-api.pages.dev/v1 |
Currencies list, EUR→USD/UAH rates, 404 for unknown currency |
| Bank Holidays API | gov.uk/bank-holidays.json |
Events count > 0, Easter date format (YYYY-MM-DD) |
| Cat Facts API | catfact.ninja |
Breed structure, fact format, ?limit=3 param, response headers |
| Dictionary API | dictionaryapi.dev |
Example usage for 5 words: hello, world, science, test, love |
// Parametrized test across multiple words
const words = ['hello', 'world', 'science', 'test', 'love'];
for (const word of words) {
test(`Check examples for word "${word}"`, async () => {
const res = await pactum.spec()
.get(`https://api.dictionaryapi.dev/api/v2/entries/en/${word}`)
.expectStatus(200);
const hasExample = res.json[0].meanings
.some(m => m.definitions.some(d => d.example));
expect(hasExample).toBe(true);
});
}| Technology | Usage |
|---|---|
| JavaScript | Primary language |
| Jest | Unit testing & API testing runner |
| Selenium WebDriver | Browser automation (Chrome) |
| Cucumber | BDD framework with Gherkin syntax |
| Pactum | REST API testing library |
| # | Topic | Framework | Test Target | Status |
|---|---|---|---|---|
| Lab 4 | Unit Testing & Mocking | Jest | JS classes, async functions | ✅ Done |
| Lab 5 | Browser Automation Basics | Selenium + Jest | Wikipedia | ✅ Done |
| Lab 6 | Page Testing (9 test cases) | Selenium + Jest | automationexercise.com | ✅ Done |
| Lab 7 | Real-World Site Testing | Selenium + Jest | hotline.ua | ✅ Done |
| Lab 8 | BDD with Gherkin | Cucumber + Selenium | automationexercise.com | ✅ Done |
| Lab 9 | API Testing | Jest + Pactum | Currency, Holidays, CatFacts, Dictionary APIs | ✅ Done |
| File | Description |
|---|---|
| ЛР1.pdf | Lab 1 written report |
| ЛР2.pdf | Lab 2 written report |
| ЛР3.pdf | Lab 3 written report |