Sunday, January 17, 2016

Selenium logging for RemoteWebDriver


On enable logging on any any driver like RemoteWebDriver/ FirefoxDriver/ Chrome driver we can implement logging in the following ways.

Steps:
1. Create an object of LoggingPreferences Class.
2. Use the method enable from LoggingPreferences which takes two arguments log type and level.
3. Now create an object of DesireCapabilities
4. Use the method setCapabilities (String , Object )from DesiredCapabilities.
5. Use Interface CapabilityType and it's static final String Fields for String argument and log object on object argument.



Now for capturing the log use driver.manage.logs();
Use the method log.get(logtype.DRIVER) I am capturing the log of only Drive. This return me an entry object. I can iterate over the entry object to get log message and log time stamp. The log timestamp is returned as long EPOCH. Convert EPOCH to date time


No comments:

Post a Comment