Here is a basic automation testing tool built with JavaScript using Selenium WebDriver for browser automation. This tool automatically tests whether a login page works as expected.
- Tools Used:
Node.js (runtime)
Selenium WebDriver (browser automation)
Mocha (test runner)
Chai (assertion library)
🔧 Step-by-step Instructions
1. Install Prerequisites
Make sure Node.js is installed. Then in your terminal:
bash
Copy
Edit
mkdir automation-test-tool
cd automation-test-tool
npm init -y
2. Sample Web Page to Test (Optional)
You can use this sample login page (save it as login.html):
html
Copy
Edit
Login Page
Login
-- How to Perform Work Testing of an Automation Tool Let’s break it down into simple 5 steps using an example (a login form automation tool):
Step 1: Define the Test Case You must define what the tool is supposed to test. -- Example Test Cases: Test Case ID Description Input Expected Output TC01 Successful login with valid credentials username: admin, password: 1234 "Login successful" TC02 Login failure with wrong credentials username: wrong, password: wrong "Invalid credentials"
Step 2: Execute the Automation Tool Use the automation tool to execute those test cases. If using the Node.js + Selenium tool mentioned earlier, run: bash Copy Edit npx mocha test/loginTest.js
Step 3: Observe the Output Watch the terminal/console output. You should see: bash Copy Edit Login Page Automation Test ✓ should display success message on correct login ✓ should show error on wrong login
2 passing ✔ This means your tool is working as expected. Step 4: Verify in the Browser (Optional) While the tool is running, you can visually observe the browser: The browser will launch. Inputs will be automatically typed in. Buttons clicked. Output verified. This is called UI verification.
Step 5: Automate Repeated Runs (Optional)
To ensure stability, run the test multiple times, or integrate it with CI/CD (like GitHub Actions or Jenkins).
-- BONUS: Add More Test Cases
You can add more test logic like:
it('should show error if username is empty', async () => {
await driver.get('http://localhost:5500/login.html');
await driver.findElement(By.id('username')).clear();
await driver.findElement(By.id('password')).sendKeys('1234');
await driver.findElement(By.id('loginBtn')).click();
const text = await driver.findElement(By.id('result')).getText();
expect(text).to.equal('Invalid credentials');
}); -- Summary Task Tools Used Build the tool Node.js + Selenium + Mocha Run the test npx mocha test/loginTest.js Check result Console + Browser Output Add more scenarios Custom JavaScript test cases
إرسال تعليق