Data driven framework for selenium webdriver software testing tool must have facility to Insert test execution log to track the execution process, debugging and failures after completion of software test. Test execution logs will helps you to track your software test execution steps. In STEP 17, We have successfully reported test cases results In excel file. Now let us Implement log generation function In our selenium webdriver software automation testing framework.
Prerequisite : Previous all 17 steps of selenium webdriver data driven framework creation should be Implemented. You will find the links for all previous steps on THIS PAGE.
For log generation, We will use Apache Log4j Logging service. It Is very good service to generate test execution log for our selenium webdriver data driven framework project.
How To Generate Log
As you know, We have already added required Apache Log4j software Logging service jar file "log4j-1.2.17.jar" In our project's build path during webdriver framework creation STEP 3 and STEP 4. If you have not followed those steps then please do so. So now you are ready to use Apache Log4j Logging service.
Now, You have to add "log4j.properties" file under "src" folder of your project. "log4j.properties" file contains all the settings for log generation. I have prepared "log4j.properties" file with all the required settings to generate the test execution log.
Also you have to create "applog.log" file under "com.stta.Logging" package to store the execution log.
Download Required Files To Enable Logging
As described above, you need "log4j.properties" and "applog.log" files to generate and store execution log.
- I have created "log4j.properties" file and set all required properties to generate execution log.
- I have created "applog.log" file. "applog.log" file Is just blank file to store log In It.
- I have Implemented sample Logs In "SuiteBase.java", "SuiteOneBase.java" and "SuiteOneCaseOne.java" files to explain you how to generate test execution log.
- Right now, I have Implemented test execution log only In "SuiteOneCaseOne.java" test case. Based on that, You can Implement test execution log In all other test cases too by your self.
- Paste log4j.properties File on "src" folder of "WDDF" project.
- Paste applog.log File on com.stta.Logging Package.
- Paste SuiteBase.java File on com.stta.TestSuiteBase Package.
- Paste SuiteOneBase.java File on com.stta.SuiteOne Package.
- Paste SuiteOneCaseOne.java File on com.stta.SuiteOne Package.
Now your selenium webdriver data driven framework project's structure will look like bellow.
Running Test To Generate Execution Log
Now we are ready to run our software test suites to verify that execution log Is generated as expected or not. Run your test suites using testng.xml file.
On completion of test execution, execution log will be generated and stored Inside applog.log file. If you will open applog.log file, It will looks like bellow.
Note : Above log Is only for "SuiteBase.java", "SuiteOneBase.java" and "SuiteOneCaseOne.java" files. You can Implement log In all your test cases In same way. You can use bellow given syntax to Insert log In any test case or suite files.
Add_Log.info("Your Log Text");
So we have successfully Implemented test execution log generation function In our selenium automation framework, And now our selenium software test data driven framework Is able to generate test execution log.