Skip to content

reportportal/logger-java-selenide

Repository files navigation

Report Portal logger for Selenide

Maven Central CI Build codecov Join Slack chat! stackoverflow Build with Love

The latest version: 5.2.2. Please use Maven Central link above to get the agent.

Overview

Selenide step logging listener for Report Portal. The listener listen for Selenide log events and send them to Report Portal as steps. It has ability to log screenshots and page sources on failure, this is enabled by default. Also, it is possible to attach different types of WebDriver logs on failure.

Configuration

Build system configuration

You need to add the logger as one of your dependencies in Maven or Gradle.

Maven

pom.xml

<project>
    <!-- project declaration omitted -->

    <dependencies>
        <dependency>
            <groupId>com.epam.reportportal</groupId>
            <artifactId>logger-java-selenide</artifactId>
            <version>5.2.2</version>
        </dependency>
    </dependencies>

    <!-- build config omitted -->
</project>

Gradle

build.gradle

dependencies {
    testCompile 'com.epam.reportportal:logger-java-selenide:5.2.2'
}

Selenide configuration

To start getting Selenide step logging in Report Portal you need to add the logger to SelenideLogger listeners. The best place for it is one which will be initialized at the earliest moment once during the test execution. E.G. a static initialization block in a base class for all tests:

public class BaseTest {
	static {
		SelenideLogger.addListener("Report Portal logger", new ReportPortalSelenideEventListener());
	}
}

Logger configuration

Screenshots and page sources

The logger has screenshots and page sources logging enabled by default. It logs them inside the step on every failure. To disable / enable this behavior we have separate setters methods in the logger. E.G.:

public class BaseTest {
	static {
		SelenideLogger.addListener("Report Portal logger", 
                new ReportPortalSelenideEventListener().logScreenshots(false).logPageSources(false));
	}
}

This disables both: screenshot and page sources logging.

Selenium logs

The logger can also attach Selenium logs on step failure. To enable it you need to call specific setter method inside the listener and bypass desired log type and level:

public class BaseTest {
	static {
		SelenideLogger.addListener("Report Portal logger",
				new ReportPortalSelenideEventListener().enableSeleniumLogs(LogType.BROWSER, Level.FINER));
	}
}

Step name sanitizing

If you need to hide some secret data from you step logs you can do this by specifying step name converter in logger constructor.

public class BaseTest {
	static {
		SelenideLogger.addListener("Report Portal logger", 
                new ReportPortalSelenideEventListener(LogLevel.INFO, l -> l.replaceAll("secret_token=[^&]*", "secret_token=<removed>")));
	}
}