Scenario is for example: I am automating a form (containing text fields, checkbox...) and using log file to print logs. Here i wanted to print the logs in text file. can anyone help me out?
You can use either basic language tool-set for logging or use well-known logging frameworks:
- This is the example on how to use log4j framework in Java
- This is the example on how to use log4net framewrok in C#
- This is the example on how to use Python logging feature
So for making meaningful logs I'd suggest to have at least following information for each record:
- Test Name
- Step Description
- Locator used
- User friendly definition of the object you're interacting with
You should also consider that normally the log messages can have different types. Some messages can be logged as Info some as Debug, some as Trace. Those type distinguish the level of details that is logged within those message. Then having such the messages segregated you can filter them using your logging framework configuration.