Logs play an important part in debugging activities of your Selenium script. Eclipse IDE does a decent job at showing logs in its console. And because these logs gets cleared each time you perform test run, you may want to log Eclipse console to file(as a text file). Eclipse provides an option to do so which we will see in this article.
Below are steps to enable this functionality in Eclipse IDE. These steps assumes you are using TestNG framework for your Selenium project. However, it should be similar for other frameworks as well.
- Create an empty text file anywhere in your system.
- Right click your TestNG XML file in Eclipse and select Run As–>Run Configurations option.
- Select ‘Common’ tab from opened Run Configurations dialog box.
- Check ‘File’ option and provide a path to your text file as shown in screenshot below.
- Check ‘Append’ option if you want to append the log of next test run. Leave it unchecked otherwise.
- Click Apply button and then Run button.
- Once the test run is completed, Eclipse console log should be displayed in specified text file.
As the above procedure would log Eclipse console to file, you can later on review it for debugging your Selenium project. Did you like this simple tip? Let us know in comments.