Вот по этой ссылке настроил логирование, все работает. Решил подключить allure
POM.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.autoadmin.sl</groupId>
<artifactId>SL_AdminUIAF</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SL_AdminUI</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<aspectj.version>1.8.4</aspectj.version>
<allure.version>1.4.5</allure.version>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/main/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<testFailureIgnore>false</testFailureIgnore>
<argLine>
-Dfile.encoding=UTF-8
-javaagent:${settings.localRepository}\org\aspectj\aspectjweaver\${aspectj.version}\aspectjweaver-${aspectj.version}.jar
</argLine>
<!--<properties>
<property>
<name>listener</name>
<value>ru.yandex.qatools.allure.testng.AllureTestListener</value>
</property>
</properties>-->
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<!-- <plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<webAppSourceDirectory>d:/qwerty/site/allure-maven-plugin</webAppSourceDirectory>
</configuration>
</plugin>-->
</plugins>
</build>
<dependencies>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-testng-adaptor</artifactId>
<version>${allure.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.7.Final</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>1.1.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.44.0</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>ru.stqa.selenium</groupId>
<artifactId>webdriver-factory</artifactId>
<version>1.1.43</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
</dependency>
</dependencies>
<reporting>
<excludeDefaults>true</excludeDefaults>
<plugins>
<plugin>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</reporting>
</project>
Но как только запускаю браузер, мне пишет следующее:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/dgrigoriev/.m2/repository/org/slf4j/slf4j-log4j12/1.7.7/slf4j-log4j12-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/dgrigoriev/.m2/repository/ch/qos/logback/logback-classic/1.1.2/logback-classic-1.1.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See SLF4J Error Codes for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
Я так понимаю было найдено 2 одинаковых файла, и один из них будет использоваться. Но при выполнении теста лог не создается и в консоле также не отображаются шаги.
P.S. сам класс описан следующим образом:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class WebDriverLogger extends AbstractWebDriverEventListener {
private static final Logger log = LoggerFactory.getLogger(WebDriverLogger.class);
@Override
public void beforeNavigateTo(String url, WebDriver driver) {
log.info("WebDriver navigated to '" + url + "'");
}
@Override
public void beforeFindBy(By by, WebElement element, WebDriver driver) {
log.info("Locator of element - " + by.toString());
waitCounter(driver);
}
@Override
public void afterFindBy(By by, WebElement element, WebDriver driver) {
waitCounter(driver);
}
@Override
public void beforeClickOn(WebElement element, WebDriver driver) {
log.info("WebDriver before click on element - "
+ elementDescription(element));
}
@Override
public void afterClickOn(WebElement element, WebDriver driver) {
waitCounter(driver);
}
@Override
public void afterChangeValueOf(WebElement element, WebDriver driver) {
log.info("WebDriver changed value for element - "
+ elementDescription(element));
waitCounter(driver);
}
public void onException(Throwable throwable, WebDriver driver) {
Writer writer = new StringWriter();
PrintWriter error = new PrintWriter(writer);
throwable.printStackTrace(error);
log.info(writer.toString());
}
private String elementDescription(WebElement element) {
String description = "tag:" + element.getTagName();
if (element.getAttribute("id") != null) {
description += " id: " + element.getAttribute("id");
}
else if (element.getAttribute("name") != null) {
description += " name: " + element.getAttribute("name");
}
description += " ('" + element.getAttribute("value") + "')";
return description;
}
private void waitCounter(WebDriver driver){
(new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("span[request-count='0']")));
}
}
В чем может быть проблема?