Automation testing comes ahead of manual testing.
Manual testing should be done extensively on an application under test so that manual test cases become reliable.
They should be executed at least once and on their basis, automation scripts have to be made.
Let’s assume a simple scenario of logging onto Facebook. This test case is very simple when you look at the manual test steps.
|Step No||Precondition||Step||Test Data||Expected Result||Actual Result|
|1||Google Chrome is launched and ready to use||Hit URL||www.facebook.com||The Facebook homepage opens|
|2||User Name and Password||Enter Username and Passwordfirstname.lastname@example.org
|Username and Password are entered|
|3.||Click on Sign In||The user is logged in facebook|
The Process of Translation of Manual Test cases to automation scripts
There are various steps involved in translating manual test scripts to automation.
Steps which are required for testing and which needs to be automated.
State of the Application -> Test Steps -> Verification and Validation -> Test Data -> Results -> Post Operation
1. State of Application
It is the precondition for the test to be automated. These requisites should be there to perform a particular step.
Let’s say if you want to begin a test, you need a browser on which you can perform all these operations.
The Browser should be launched and should be ready to use. But you must be wondering how you would be doing in automation.
It depends on which automation tool you are using.
If you are using Selenium, then you can just have a reference variable of WebDriver and make the object of the browser you want to instantiate.
WebDriver driver = new FirefoxDriver(); // for firefox driver.
System.setProperty(“webdriver.chrome.driver”,”Path of Chrome driver”);
WebDriver driver = new ChromeDriver(); // for chrome driver
System.setProperty(“webdriver.ie.driver”,”Path of ie driver”);
WebDriver driver = new InternetExplorerDriver(); // for ie driver
This way, you will be able to instantiate your browser in your test. Your browser would then be ready for use and for execution of the step.
Also, if you want step number 2 to get completed then you have to wait for step number 1 to get completed.
In manual testing, it is very easy but in automation testing, you have to wait for step number 1 to get executed.
You can achieve this by adding waits in between. Wait can be both explicit and implicit.
If you are expecting the particular condition to be attained then you can use explicit wait while if you just want a global wait, then you can go ahead to use implicit wait.
A perfect automation script is made by adding both type of waits – Explicit and Implicit.
Syntax of Explicit Wait:
WebDriverWait wait = new WebDriverWait(WebDriverRefrence,TimeOut);
Expected Condition can be used with so many conditions. Some conditions which can be used with it are:
The syntax of Implicit Wait:
2. Test Steps
Test Steps would be written in your script itself.
It should have logical names of variables so that machine and anyone can understand what’s happening in the system.
You have to add for all steps verification and validation because the assertions will only tell whether the step got passed or not.
Make sure to add comments for more readability. You can even add debugging statements to test if it got stuck at one particular point.
Along with this, you should have output statements so that the output can be written to a console.
3. Verification and Validation
Testing has verification and validation as its core part. Without it, it is baseless.
You should have so many checkpoints, conditional statements, and loop statements.
These should be used to effectively test the application under test.
For example: in the above scenario, you can create validation steps of the login page of Facebook.
You can test the text of the logo of Facebook or the title of the page so as to make sure whether you have landed onto the right page or not.
Also, after entering username and password you can have more assertions added in your test case to check whether you have successfully signed in or not.
4. Test Data
Test Data is a very crucial part of testing. First thing is to decide where you must place this data.
The simplest answer to this is an Excel sheet. You must hard code the data or not.
For this, you can use an excel sheet to store the data and then fetch the data from it to use on your test case.
File file = new File(“Path of Excel Sheet”);
FileInputStream fis = new FileInputStream(file);
XSSFWorkbook wb = new XSSFWorkbook(fis);
Sheet sh = wb.getSheet(sheetName);
In this way, you can access the sheet and then fetch the data from it according to your test requirements.
You need something to post your results.
Your automation tool should have some good reporting add-on so that you can get some good quality reports.
You can leverage TestNG for this. Or you can prefer Behaviour Driven development framework like cucumber to get reports.
Allure reports even give you more advances presentation of reports. These all options can be integrated with your test to make the result look more attractive.
6. Post Operation
After the execution of the test step, it is very important to close the browser.
In automation, once the script has been executed, you should close the browser diligently by using
Driver.quit(); // for closing all the sessions opened by selenium
Driver.close(); // for closing the browser on which operation is performed.
Thus you will be able to automate your manual test steps following this.
You can have the regression suite running after all steps are automated to know which functionality is having most of the bugs.
All the best!