需要帮助,原因是:org.apache.maven.surefire.booter.SurefireBooterWorkException:分叉进程中出现错误

r8xiu3jd  于 2021-08-25  发布在  Java
关注(0)|答案(1)|浏览(303)

有人能帮我吗?我有3个月没有打开测试,现在我试图继续编写测试,但启动后出现错误,浏览器在启动后刚刚关闭。但3个月前,这项工作没有任何问题。
testng版本7.4.0
maven版本ApacheMaven 3.8.1
jdk版本1.8.0192
以下是错误日志:

org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process

Cannot instantiate class com.test.test.test.ComparePricesTest
        at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:733)
        at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:305)
        at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:265)
        at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1314)
        at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1159)
        at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:932)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

这里还有来自surefire的日志:

org.testng.TestNGException: 
Cannot instantiate class com.test.test.test.ComparePricesTest
    at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:30)
    at org.testng.internal.InstanceCreator.instantiateUsingDefaultConstructor(InstanceCreator.java:193)
    at org.testng.internal.InstanceCreator.createInstanceUsingObjectFactory(InstanceCreator.java:113)
    at org.testng.internal.InstanceCreator.createInstance(InstanceCreator.java:79)
    at org.testng.internal.objects.SimpleObjectDispenser.dispense(SimpleObjectDispenser.java:25)
    at org.testng.internal.objects.GuiceBasedObjectDispenser.dispense(GuiceBasedObjectDispenser.java:30)
    at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:112)
    at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:165)
    at org.testng.TestClass.getInstances(TestClass.java:122)
    at org.testng.TestClass.initTestClassesAndInstances(TestClass.java:102)
    at org.testng.TestClass.init(TestClass.java:94)
    at org.testng.TestClass.<init>(TestClass.java:59)
    at org.testng.TestRunner.initMethods(TestRunner.java:463)
    at org.testng.TestRunner.init(TestRunner.java:339)
    at org.testng.TestRunner.init(TestRunner.java:292)
    at org.testng.TestRunner.<init>(TestRunner.java:183)
    at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:596)
    at org.testng.SuiteRunner.init(SuiteRunner.java:173)
    at org.testng.SuiteRunner.<init>(SuiteRunner.java:107)
    at org.testng.TestNG.createSuiteRunner(TestNG.java:1300)
    at org.testng.TestNG.createSuiteRunners(TestNG.java:1276)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1125)
    at org.testng.TestNG.runSuites(TestNG.java:1063)
    at org.testng.TestNG.run(TestNG.java:1031)
    at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:284)
    at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
    at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:119)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:428)
    at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
    at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:562)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:548)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:23)
    ... 30 more
Caused by: org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 89
Current browser version is 91.0.4472.114 with binary path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'Seregas-MacBook-Pro.local', ip: 'fe80:0:0:0:14b6:66e6:a891:514b%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '1.8.0_291'
Driver info: driver.version: Driver
remote stacktrace: 0   chromedriver                        0x000000011011fb59 chromedriver + 2595673
1   chromedriver                        0x00000001107d3b33 chromedriver + 9624371
2   chromedriver                        0x000000010fecf773 chromedriver + 169843
3   chromedriver                        0x000000010fef3bf6 chromedriver + 318454
4   chromedriver                        0x000000010feefdc4 chromedriver + 302532
5   chromedriver                        0x000000010feed032 chromedriver + 290866
6   chromedriver                        0x000000010ff20234 chromedriver + 500276
7   chromedriver                        0x000000010ff1b4f3 chromedriver + 480499
8   chromedriver                        0x000000010fef5cd6 chromedriver + 326870
9   chromedriver                        0x000000010fef6ba7 chromedriver + 330663
10  chromedriver                        0x00000001100edb09 chromedriver + 2390793
11  chromedriver                        0x00000001100fabcc chromedriver + 2444236
12  chromedriver                        0x00000001100fa6ee chromedriver + 2442990
13  chromedriver                        0x00000001100d4832 chromedriver + 2287666
14  chromedriver                        0x00000001100fb63f chromedriver + 2446911
15  chromedriver                        0x00000001100e3299 chromedriver + 2347673
16  chromedriver                        0x00000001101128b9 chromedriver + 2541753
17  chromedriver                        0x0000000110125008 chromedriver + 2617352
18  libsystem_pthread.dylib             0x00007fff707db2eb _pthread_body + 126
19  libsystem_pthread.dylib             0x00007fff707de249 _pthread_start + 66
20  libsystem_pthread.dylib             0x00007fff707da40d thread_start + 13

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
    at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
    at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
    at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:134)
    at com.test.webdriverfactory.Driver.getWebDriverInstance(Driver.java:19)
    at com.test.helpers.AppManager.<init>(AppManager.java:17)
    at com.test.helpers.SingletoneManager.<init>(SingletoneManager.java:10)
    at com.test.helpers.SingletoneManager.getInstance(SingletoneManager.java:15)
    at com.test.testConfig.TestBase.<init>(TestBase.java:15)
    at com.test.test.test.ComparePricesTest.<init>(ComparePricesTest.java:6)

这里是我的pom文件:

<groupId>TestP</groupId>
    <artifactId>testP</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <aspectj.version>1.9.4</aspectj.version>
        <maven-surefire-plugin-version>3.0.0-M5</maven-surefire-plugin-version>
        <maven-compiler-plugin-version>3.8.1</maven-compiler-plugin-version>
        <local.repo>${settings.localRepository}</local.repo>
        <suiteFile>full</suiteFile>
        <allure.results>${project.build.directory}/allure-results</allure.results>
        <allure-testng-version></allure-testng-version>
    </properties>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.testng/testng -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.4.0</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler-plugin-version}</version>
            <type>maven-plugin</type>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <version>2.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-java-commons</artifactId>
            <version>2.6.0</version>
        </dependency>

    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin-version}</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin-version}</version>
                <configuration>
                    <includes>
                        <include>**/*.java</include>
                    </includes>
                    <argLine>
                        -javaagent:${local.repo}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
                    </argLine>
                    <testFailureIgnore>true</testFailureIgnore>
                    <suiteXmlFiles>
                        <suiteXmlFile>${basedir}/src/test/resources/${suiteFile}.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-maven</artifactId>
                <version>2.10.0</version>
                <configuration>
                    <reportVersion>2.13.3</reportVersion>
                    <allureDownloadUrl>
                        https://dl.bintray.com/qameta/maven/io/qameta/allure/allure-commandline/2.13.3/allure-commandline-2.13.3.zip
                    </allureDownloadUrl>
                    <reportDirectory>${project.build.directory}/allure-reports</reportDirectory>
                </configuration>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources/</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
    <profiles>
        <profile>
            <id>full</id>
            <properties>
                <suiteFile>full</suiteFile>
            </properties>
        </profile>
        <profile>
            <id>smoke</id>
            <properties>
                <suiteFile>smoke</suiteFile>
            </properties>
        </profile>
    </profiles>

</project>

**TestBase class:**
static WebDriver driver;

protected AppManager app = SingletoneManager.getInstance().app;

@BeforeClass(description = "Open homepage")
public void openBrowser()  {
  driver = app.getDriver();
  app.getNavigationHelper().navigateToHomePage();

}

@AfterSuite(description = "Close browser")
public void closeBrowser(){
    driver.quit();
}

public static WebDriver getDriver(){return driver;}

appmanager类:

AppManager(){
        driver = getWebDriverInstance();
        wait = new WebDriverWait(driver, 10);

        attributeHelper = new AttributeHelper(driver, wait);
        navigationHelper = new NavigationHelper(driver, wait);

    }

    public AttributeHelper getAttributeHelper() {
        return attributeHelper;
    }

    public NavigationHelper getNavigationHelper() {
        return navigationHelper;
    }

    public WebDriver getDriver(){
        return driver;
    }
}

辛格尔顿级

public class SingletoneManager {

    private static SingletoneManager singletoneManager = null;

    public AppManager app;

    private SingletoneManager(){
      app = new AppManager();
    }

    public static synchronized SingletoneManager getInstance(){
        if(singletoneManager == null)
            singletoneManager = new SingletoneManager();
        return singletoneManager;
    }
}

和比较价格类别:

public class ComparePricesTest extends TestBase {

    @Test(priority = 0, description = "click on Deal")
    public void getDeal() throws InterruptedException {
        app.getNavigationHelper().clickOnDealBtn();
        Thread.sleep(5000);
    }

    @Test(priority = 1)
    public void ComparePrice() throws InterruptedException {
        Thread.sleep(8000);
        app.getAttributeHelper().getOfferPriceOnSearchResultPage();
        Thread.sleep(5000);
    }
}
uqzxnwby

uqzxnwby1#

将maven surefire插件降级到2.19.1应该可以解决这个问题。您还发现chrome drver 89不支持chrome 91的错误。您可能需要将chrome驱动程序89升级到91。

相关问题