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.
STEP 18
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.
Extract the folder and copy-paste files as described bellow.
- 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.
I am not able to generate the logs. I am getting error SuiteOneCaseTwo.java File. I disabled by selecting "N" in SuiteOne.xls file still SuiteOneCaseTwo.java File is getting executed.
ReplyDeleteI am able to do all steps except Step 18. Please help me in fixing this.
I am not able to generate logs in applog.log file
ReplyDelete
ReplyDeleteI am getting below error after implementing log4j
log4j:WARN No appenders could be found for logger (rootLogger).
log4j:WARN Please initialize the log4j system properly.
I am not able to generate log file .
any help
Regards
Sruthi
add this line
ReplyDeletePropertyConfigurator.configure("Log4j.properties");
below
Add_Log = Logger.getLogger("rootLogger");
in suitBase.java
No logs are generated in applog file even after adding this.
DeletePropertyConfigurator.configure("C:\\Log4j.properties"); //provide the complete path for log4j properties file
Deleteand
Yuou find the line "log4j.appender.R.Append=false" in Log4j.properties file in line 10 and change it to true
Hi Arvind,
ReplyDeleteNo new logs are appended after we follow the instruction on your page.
Thanks
Prashant
Everything worked perfectly till step 18... thanks for this tutorial..
ReplyDeletewould appreciate if a detailed explanation of workflow is published..