M1 Mac:java.lang.exceptioninitializererror at Cucumber.deps.com.thoughtworks.xstream.xstream.xstream.setupconverters(xstream.java:820)
我试图通过使用Chrome驱动程序启动Chrome浏览器来运行自动化测试。
设置:
Chip: Apple M1 Pro
OS: macOS Monterey
JDK: jdk-18.0.1.1.jdk
Maven: Apache Maven 3.8.5
IntelliJ IDEA 2022.1.1 (Community Edition)Build #IC-221.5591.52
运行代码时,我会收到以下错误: 您能建议解决方案吗?不知道设置,版本,POM或Chromedriver路径有问题:
java.lang.exceptioninitializererror at Cucumber.deps.com.thoughtworks.xstream.xstream.xstream.setupconverterters(xstream.java:820)cucumber.deps.com.thoughtworks.thoughtworks.xstream.xstream.xstream.xstream.xstream.xstream.java.java:574) cucumber.deps.com.thoughtworks.xstream.xstream。(xstream.java:530)在cucumber.runtime.xstream.xstream.localizedxstreams $ localizedxstreams。 java:37) at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:29) at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37) at cucumber.runtime.Runtime.runStep(Runtime.java:300 )在cucumber.runtime.model.stepcontainer.runstep(stepcontainer.java:44)incucumber.runtime.model.model.stepcontainer.runsteps(stepcontainer.java:39) 44)在cucumber.runtime.model.cucumberfeature.run(cucumberfeature.java:165)cucumber.runtime.runtime.runtime.run(runtime.java:122),cucumber.cli.api.api.cli.main.main.main.java:36 )在cucumber.api.cli.main.main(main.java:18)at?given i启动浏览器(/USERS/RAVITHAPA/ideaprojects/retstry/src/src/test/resources/resources/features/features/homepagelogo_logogin.feature:5)引起的: .base/java.lang.reflect.AccessibleObject.CheckCansetAccessible(AccessibleObject.java:354) 。 (Fields.java:39) at cucumber.deps.com.thoughtworks.xstream.converters.collections.TreeMapConverter.(TreeMapConverter.java:50) at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters(XStream.java: 820)在cucumber.deps.com.thoughtworks.xstream.xstream.(xstream.java:574)cucumber.deps.com.thoughtworks.xstream.xstream.xstream.xstream.xstream.xstream.java.java:530)在cucumber.runtime.xstream.xstream.xstream.xstream.localizedxstreamsemizedxstreamsexstreamssssss $LocalizedXStream.(LocalizedXStreams.java:50) at cucumber.runtime.xstream.LocalizedXStreams.newXStream(LocalizedXStreams.java:37) at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:29) at cucumber.runtime.StepDefinitionMatch cucumber.runtime.runtime.runstep(runtime.java:300)上的。 runSteps(StepContainer.java:39) at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44) at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165) at cucumber.runtime.Runtime.run (runtime.java:122)在cucumber.api.cli.main.run(main.java:36)incucumber.api.cli.cli.main.main.main(main.java:18)
pom file: 4.0.0
<groupId>org.example</groupId>
<artifactId>letstry</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>2.8.0</version>
<executions>
<execution>
<id>execution</id>
<phase>test</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>e2e</projectName>
<outputDirectory>${project.build.directory}/cucumber-report-html</outputDirectory>
<cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-picocontainer -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/gherkin -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.28</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-htmlunit-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.48.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
</properties>
代码:
public WebDriver driver;
@Given("^I launch a browser$")
public void i_launch_a_browser() throws Throwable {
public class Homepagelogo_Login {
public WebDriver driver;
@Given("^I launch a browser$")
public void i_launch_a_browser() throws Throwable {
System.setProperty("webdriver.chrome.driver", "/Users/me/Desktop/test/webdriver");
driver = new ChromeDriver();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在IDE的运行配置中添加以下以下内容:
参考:
上述链接(如果您正在运行
mvn test test
反而。Add following to the VM options in the Run configuration of your IDE:
Reference from here: https://github.com/Riduidel/aadarchi/issues/90#issuecomment-1291640544
The above link also has sample code to use in pom.xml if you are running a
mvn test
instead.