我使用以下依赖项通过以下命令打开浏览器
chrome:
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
firefox:
WebDriverManager.firefoxdriver().arch64().setup();
driver = new FirefoxDriver();
依赖性:
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
对于Chrome浏览器,它正在运行。但是对于Firefox,我遇到了一些问题,
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[ERROR] Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 6.931 s <<< FAILURE! - in TestSuite
[ERROR] Test(com.Googlesearch.automation.DemoforGoogle) Time elapsed: 4.397 s <<< FAILURE!
org.openqa.selenium.SessionNotCreatedException:
Unable to find a matching set of capabilities
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-0Q6C6CP', ip: '192.168.1.100', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_171'
Driver info: driver.version: FirefoxDriver
remote stacktrace:
at com.Googlesearch.automation.DemoforGoogle.CheckGooglechrome(DemoforGoogle.java:19)
at com.Googlesearch.automation.DemoforGoogle.Test(DemoforGoogle.java:35)
[ERROR] Test1(com.Googlesearch.automation.DemoforGoogle) Time elapsed: 1.873 s <<< FAILURE!
org.openqa.selenium.SessionNotCreatedException:
Unable to find a matching set of capabilities
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-0Q6C6CP', ip: '192.168.1.100', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_171'
Driver info: driver.version: FirefoxDriver
remote stacktrace:
at com.Googlesearch.automation.DemoforGoogle.CheckGooglechrome(DemoforGoogle.java:19)
at com.Googlesearch.automation.DemoforGoogle.Test1(DemoforGoogle.java:40)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] DemoforGoogle.Test:35->CheckGooglechrome:19 » SessionNotCreated Unable to find...
[ERROR] DemoforGoogle.Test1:40->CheckGooglechrome:19 » SessionNotCreated Unable to fin...
[INFO]
[ERROR] Tests run: 2, Failures: 2, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.193 s
[INFO] Finished at: 2018-11-25T19:43:17+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project com.Googlesearch.automation: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\Hp\workspace\com.Googlesearch.automation\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
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>com.Google.automation</groupId>
<artifactId>com.Googlesearch.automation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<suiteXmlFile>src/main/resources/testng.xml</suiteXmlFile>
</properties>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
请帮助我,希望我需要更改Firefox浏览器的代码或依赖项