我是Selenide的新手,并尝试使用Selenide和Junit依赖项运行浏览器。但是,我得到了
slf4j:无法加载类" org.slf4j.impl.staticloggerbinder"错误。任何思想?
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>1</groupId>
<artifactId>1</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- https://mvnrepository.com/artifact/com.codeborne/selenide -->
<dependencies>
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>selenide</artifactId>
<version>4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-nop -->
import com.codeborne.selenide.Configuration;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static com.codeborne.selenide.Selenide.close;
import static com.codeborne.selenide.Selenide.open;
public class ChromeStart {
@Before
public void RunURL() {
Configuration.browser= "chrome";
open ("http://google.com");
}
@Test
public void StartBrowser() {
System.out.println("Hello world")
}
@After
public void CloseURL(){
close();
}
}
很可能此错误是由于缺失依赖性的结果。尝试在pom.xml文件中添加以下依赖关系并再次运行测试。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4jnop</artifactId>
<version>1.7.21</version>
</dependency>