In the second post on the Five Questions Series, we have Sahi Logs today.
If you have not checked out our previous thread on Sahi Controller, click here.
How do you configure Sahi Logs?
There is no need to configure Sahi Logs separately. It is by default in-built within Sahi Pro. You need not write separate code to setup Sahi Logs. One can access Logs by clicking on Logs link from Sahi Dashboard or Sahi Script Editor. There is an option to view logs from Sahi Controller too.
What are the capabilities present in Sahi Logs?
For every script/suite played via Sahi, a log file is created. On clicking on Logs link, a window with the results in HTML is displayed. One can filter the results by using pagination tool or using SQL query.
The core capabilities include
– Logs for every script/suite
– Code Folding: When a function is called in a Sahi script, the logs for the function call are automatically “folded” in the reports
– Color coding of scripts, asserts and functions in red/green based on failure/success
– Script wise and Test Case wise summary
– Graphical representation of all scripts/suites run so far
– Comparison of suites where we can also compare screenshots, logs across scripts
– Detailed network activity for each request response
How can we monitor network activity in log files?
One can log HTTP request/response information for all network calls in the script. It is called HAR Logging. HAR refers to HTTP ARchive format of storing request response information. There are two ways to enable HAR Logging — globally or locally.
To enable HAR Logging Globally:
Add har_logging.enabled=true in userdata.properties and restart Sahi for this to take effect.
To enable HAR Logging Locally:
One can locally enable/disable HAR Logging inside a script using _startHarLogging() and _stopHarLogging() APIs.
An example of how HAR Logging would look is as follows:
Do logs record everything present in the script?
One has the option to mask certain information from appearing in the logs. Sometimes sensitive information like password, credit card details, bank account details may be entered via script, but we do not want it stored/displayed anywhere. We can then use APIs like _maskLogs to mask information and _unmaskLogs to start displaying steps in the playback logs and the Controller. This is mostly used after _maskLogs API.
How frequently are the logs updated?
Most of us want the logs to be up to date but do not like to refresh the logs page again and again. Auto Refresh Logs feature comes in handy here. By checking the ‘Auto Refresh Logs’ checkbox, the page is refreshed after every 2 seconds till the execution completes.
Any other questions in your mind?
Feel free to comment or ask your question(s) and we will get back to you.