Entre each class file. Create a Log property and instantiate it.
The LogManager will get the logger of the current class from the Nlog package, which means it will use the current page for logging and output it to the message;
TIps1: Each class must be written like this at the beginning of the class, and it will have the appropriate information for this class. Remember to add" Using Nlog".
Tips2: Logger cannot penetrate into your functional test cases, and cannot affect functional testing. It can only be placed in PageObject.
internal void NoInput()
{
Actions actionsObj = new Actions(Driver);
//Move the cursor From the user account to password field
actionsObj.Click(EmailAddress).Perform();
_logger.Info($"Inputed no mail address=>{EmailAddress}");
actionsObj.Click(PassWord).Perform();
_logger.Info($"Inputed no password=>{PassWord}");
actionsObj.Click(EmailAddress).Perform();
_logger.Info($"moved mouse back to login field");
}
The LogManager will get the logger of the current class from the Nlog package, which means it will use the current page for logging and output it to the message;
TIps1: Each class must be written like this at the beginning of the class, and it will have the appropriate information for this class. Remember to add" Using Nlog".
Tips2: Logger cannot penetrate into your functional test cases, and cannot affect functional testing. It can only be placed in PageObject.
We can add logger into our method:
or
Below is the NLog.config file in my project:
Test result log for login successfully.