L18 - Automation Testing
L18 - Automation Testing
1
Automation Testing Amity School of Engineering & Technology
Let's say you have a web application for an online store and want to automate the testing of the login functionality. Let’s follow the steps mentioned above to create and run the script.
Step 1: Select the right tool
We chose Selenium as our automation tool because it supports web applications and integrates well with various CI/CD tools.
Step 2: Create a framework
We set up a test automation framework using Selenium WebDriver with Java and TestNG for organizing our test cases. We also use Maven for dependency management and Jenkins for CI/CD
integration.
Step 3: Write a test script
We created a test script that contains instructions for the automated testing tool to open a web browser, navigate to the login page of your website, enter predefined username and password
credentials, click the login button, and verify that the user is successfully logged in.
WebDrive driver = new ChromeDriver ();
driver.get(“https://example.com/login”);
driver.findElement(By.id(“username”)).sendKeys(“user123”);
driver.findElement(By.id(“password”)).sendKeys(“pass123”);
driver.findElement(By.id(“loginButton”)).click();
driver.findElement(By.id(“success”));
Step 4: Perform automated testing
Execute the test script using TestNG. The tool opens a web browser, performs the actions specified in the script, and verifies the results.
Step 5: Gather results
After the test execution, TestNG generates a report indicating whether the test passed or failed. The automation tool compares the actual results (such as the appearance of the user dashboard
after login) with the expected results (as defined in the script). If the actual results match the expected results, the test case passes. If not, it fails.
Step 6: Prepare test closure reports
The automation tool generates a detailed report of the test execution, indicating which tests passed and which ones failed. It may also include logs and screenshots for further analysis.
Step 7: Integrate automation testing into CI/CD pipeline
Integrate automation testing into CI/CD pipelines, for example, using Jenkins, to ensure rapid and reliable software delivery. Whenever developers commit code changes to the version control
system, CI/CD pipelines trigger automated tests. If all tests pass, the code is automatically deployed to production.
How do you know if the test passed or failed? Well, for one, if the automated test for login functionality successfully logs in with the correct credentials and navigates to the user dashboard, the
test case is marked as passed. If, however, the login fails due to incorrect credentials, the test case is marked as failed, and the report will provide details about the failure, such as error
messages or screenshots of the unexpected behavior.
Automation testing allows for the efficient and repeatable testing of software applications, saving time and effort compared to manual testing, especially for repetitive and regression testing tasks.
10