Jenkins - Cucumber 测试集成 - 无法实例化 class base.StepDef

Jenkins - Cucumber tests integration - Failed to instantiate class base.StepDef

我已经 运行 在我的系统上成功地进行了 Cucumber 测试。我编写的测试在 Bitbucket 中进行管理。我的新任务包括将 Jenkins 与我们的 Cucumber 测试集成。我已经通过遵循在线提供的几个教程并通过在 Whosebug 上解决了一些相关问题来尝试了这一点。几乎所有这些教程都适用于 Windows 上本地安装的 Jenkins 服务器,但我的 Jenkins 服务器 运行 正在远程 CentOS 7 服务器上运行。我一直面临的错误是: cucumber.runtime.CucumberException: Failed to instantiate class base.PageStepDef

我正在使用 IntelliJ IDE 并且在移动到项目的根文件夹后,我 运行 在命令提示符下使用 mvn clean test -Dcustomer="iapps" -Denv="stage" -Dbrowser="chrome" 进行测试。我的 POM 文件位于项目的根目录,而 StepDef 和 RunTest 位于 src/test/java/base/PageStepDef.java

在 Jenkins 上,我尝试使用 Free Style ProjectMaven Project,但其中 none 正在运行。 我注意到的一个区别是在我的本地系统上 Chrome 驱动程序版本是 83.0.4103.39,而 Jenkins 使用的是 Chrome 驱动程序 2.46.628388。但我不确定是否也需要为 Jenkin 的工作更新此 Chrome 驱动程序。如果是,怎么办?谁能帮忙解决这个问题?

我的 objective 是 运行 无头的测试,我希望有一个解决方案。

这是 POM 文件:

<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>iapps-admin-portal</groupId>
  <artifactId>iapps-admin-portal</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>4.2.0</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>4.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.14.0</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-safari-driver</artifactId>
            <version>3.14.0</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-ie-driver</artifactId>
            <version>3.14.0</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-chrome-driver</artifactId>
            <version>3.14.0</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-firefox-driver</artifactId>
            <version>3.14.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <type>maven-plugin</type>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12.4</version>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.lazerycode.selenium</groupId>
                <artifactId>driver-binary-downloader-maven-plugin</artifactId>
                <version>1.0.17</version>
                <configuration>

     <rootStandaloneServerDirectory>${project.basedir}/src/test/resources/webdrivers/ 
            selenium_standalone_binaries</rootStandaloneServerDirectory>

  <downloadedZipFileDirectory>${project.basedir}/src/test/resources/webdrivers/ 
    selenium_standalone_zips</downloadedZipFileDirectory>

   <customRepositoryMap>${project.basedir}/src/test/resources/RepositoryMap.xml</customRepositoryMap>
                    <overwriteFilesThatExist>false</overwriteFilesThatExist>
                    <onlyGetDriversForHostOperatingSystem>true</onlyGetDriversForHostOperatingSystem>
                    <operatingSystems>
                        <windows>true</windows>
                        <linux>true</linux>
                        <mac>true</mac>
                    </operatingSystems>
                    <sixtyFourBitBinaries>true</sixtyFourBitBinaries>

    <throwExceptionIfSpecifiedVersionIsNotFound>true</throwExceptionIfSpecifiedVersionIsNotFound>
                    <fileDownloadRetryAttempts>3</fileDownloadRetryAttempts>
                    <fileDownloadConnectTimeout>40000</fileDownloadConnectTimeout>
                    <fileDownloadReadTimeout>30000</fileDownloadReadTimeout>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>selenium</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>net.masterthought</groupId>
                <artifactId>maven-cucumber-reporting</artifactId>
                <version>5.0.0</version>
                <executions>
                    <execution>
                        <id>execution</id>
                        <phase>test</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <projectName>ReportAutomation</projectName>
                            <!-- output directory for the generated report -->
                <outputDirectory>${project.build.directory}/ cucumber-reports</outputDirectory>
                            <!-- optional, defaults to outputDirectory if not specified -->
                            <inputDirectory>${project.build.directory}/</inputDirectory>
                            <jsonFiles>
                                <!-- supports wildcard or name pattern -->
                                <param>**/*.json</param>
                            </jsonFiles>
                            <!-- optional, defaults to outputDirectory if not specified -->

                  <classificationDirectory>${project.build.directory}/</classificationDirectory>
                            <classificationFiles>
                                <!-- supports wildcard or name pattern -->
                                <param>sample.properties</param>
                                <param>other.properties</param>
                            </classificationFiles>
                            <checkBuildResult>true</checkBuildResult>
                            <mergeFeaturesWithRetest>true</mergeFeaturesWithRetest>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

这里是 Maven 项目 的控制台输出(与上面类似):



         Running as SYSTEM
            [EnvInject] - Loading node environment variables.
            Building on master in workspace /var/lib/jenkins/workspace/CucumberTest-Maven
            using credential jenkins
             > git rev-parse --is-inside-work-tree # timeout=10
               Fetching changes from the remote Git repository
             > git config remote.origin.url ssh://git@bitbucketcloud.abc.com:1234/iap/ 
                iapps-automation-admin-portal.git # timeout=10
                Fetching upstream changes from ssh://git@bitbucketcloud.abc.com:1234/iap/
                iapps-automation-admin-portal.git
             > git --version # timeout=10
            using GIT_SSH to set credentials 
             > git fetch --tags --force --progress -- ssh://git@bitbucketcloud.abc.com:1234/iap/
                iapps-automation-admin-portal.git +refs/heads/*:refs/remotes/origin/* # timeout=10
             > git rev-parse refs/remotes/origin/auto_test^{commit} # timeout=10
             > git rev-parse refs/remotes/origin/origin/auto_test^{commit} # timeout=10
                 Checking out Revision ed379b3b59f4173aa5a768de5b1ea1e55a980a98 
                 (refs/remotes/origin/auto_test)
             > git config core.sparsecheckout # timeout=10
             > git checkout -f ed379b3b59f4173aa5a768de5b1ea1e55a980a98 # timeout=10
             Commit message: "another minor change in pom file"
             > git rev-list --no-walk ed379b3b59f4173aa5a768de5b1ea1e55a980a98 # timeout=10
               Parsing POMs
               Established TCP socket on 36183
               [CucumberTest-Maven] $ /bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/
                maven35-agent- 1.13.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation
                /mvn_3.6.1/boot/plexus-classworlds-2.6.0.jar:/var/lib/jenkins/tools/
                hudson.tasks.Maven_MavenInstallation/mvn_3.6.1/conf/
                logging jenkins.maven3.agent.Maven35Main 
                /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/mvn_3.6.1 
                /var/cache/jenkins/war/WEB-INF/lib/remoting-4.2.1.jar 
                /var/lib/jenkins/plugins/maven-plugin/
                WEB-INF/lib/maven35-interceptor-1.13.jar /var/lib/jenkins/plugins/maven-plugin/
                WEB-INF/lib/maven3-interceptor-commons-1.13.jar 36183
            <===[JENKINS REMOTING CAPACITY]===>channel started
            Executing Maven:  -B -f /var/lib/jenkins/workspace/CucumberTest-Maven/
                pom.xml clean test -Dcustomer=iapps -Denv=stage -Dbrowser=chrome
            [INFO] Scanning for projects...
            [INFO] 
            [INFO] ---------------< iapps-admin-portal:iapps-admin-portal >----------------
            [INFO] Building iapps-admin-portal 0.0.1-SNAPSHOT
            [INFO] --------------------------------[ jar ]---------------------------------
            [INFO] 
            [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ iapps-admin-portal ---
            [INFO] Deleting /var/lib/jenkins/workspace/CucumberTest-Maven/target
            [INFO] 
            [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ iapps-admin-portal ---
            [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, 
                i.e. build is platform dependent!
            [INFO] skip non existing resourceDirectory /var/lib/jenkins/workspace/
                CucumberTest-Maven/src/main/resources
            [INFO] 
            [INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ iapps-admin-portal ---
            [INFO] No sources to compile
            [INFO] 
            [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) 
            @ iapps-admin-portal ---
            [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, 
                i.e. build is platform dependent!
            [INFO] Copying 12 resources
            [INFO] 
            [INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) 
                  @ iapps-admin-portal ---
            [INFO] Changes detected - recompiling the module!
            [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. 
                build is platform dependent!
            [INFO] Compiling 10 source files to /var/lib/jenkins/workspace/CucumberTest-Maven/
            target/test-classes
            [WARNING] /var/lib/jenkins/workspace/CucumberTest-Maven/src/test/java/handler/
                SelectHandler.java:[4,49] com.sun.org.apache.xpath.internal.objects.XString is 
                internal proprietary API and may be removed in a future release
            [WARNING] /var/lib/jenkins/workspace/CucumberTest-Maven/src/test/java/
                      handler/SelectHandler.java:        
            [5,49] com.sun.org.apache.xpath.internal.objects.XStringForChars is internal proprietary API 
                and may be removed in a future release
            [WARNING] /var/lib/jenkins/workspace/CucumberTest-Maven/src/test/java/handler/
                SelectHandler.java:[11,17] sun.swing.SwingAccessor is internal proprietary API and may 
                be removed in a future release
            [WARNING] /var/lib/jenkins/workspace/CucumberTest-Maven/src/test/java/handler/
                AssertHandler.java:[7,38] com.sun.imageio.plugins.common.ReaderUtil is 
                internal proprietary 
                API and may be removed in a future release
            [INFO] /var/lib/jenkins/workspace/CucumberTest-Maven/src/test/java/base/PageStepDef.java:         
             /var/lib/jenkins/workspace/CucumberTest-Maven/src/test/java/base/PageStepDef.java 
                uses or overrides a deprecated API.
            [INFO] /var/lib/jenkins/workspace/CucumberTest-Maven/src/test/java/base/PageStepDef.java: 
                Recompile with -Xlint:deprecation for details.
            [INFO] 
            [INFO] --- driver-binary-downloader-maven-plugin:1.0.17:selenium (default) 
            @ iapps-admin-portal ---
            [INFO]  
            [INFO] --------------------------------------------------------
            [INFO]  DOWNLOADING SELENIUM STAND-ALONE EXECUTABLE BINARIES...
            [INFO] --------------------------------------------------------
            [INFO]  
            [INFO] Repository map 'file:/var/lib/jenkins/workspace/
                CucumberTest-Maven/src/test/resources/RepositoryMap.xml' is valid
            [INFO]  
            [INFO] Only get drivers for current Operating System: true
            [INFO] Getting drivers for current operating system only.
            [INFO] Archives will be downloaded to '/var/lib/jenkins/workspace/
                CucumberTest-Maven/src/test/resources/webdrivers/selenium_standalone_zips'
            [INFO] Standalone executable files will be extracted to '/var/lib/jenkins/workspace/
                CucumberTest-Maven/src/test/resources/webdrivers/selenium_standalone_binaries'
            [INFO]  
            [INFO] Preparing to download Selenium Standalone Executable Binaries...
            [INFO] Binary 'geckodriver' exists: true
            [INFO] Using existing 'geckodriver 'binary.
            [INFO] Binary 'chromedriver' exists: true
            [INFO] Using existing 'chromedriver 'binary.
            [INFO] Setting maven property - ${webdriver.gecko.driver} = 
             /var/lib/jenkins/workspace/CucumberTest-Maven/src/test/resources/webdrivers/ 
            selenium_standalone_binaries/linux/marionette/64bit/geckodriver
            [INFO] Setting maven property - ${webdriver.chrome.driver} = 
             /var/lib/jenkins/workspace/CucumberTest-                        
             Maven/src/test/resources/webdrivers/selenium_standalone_binaries/linux/
                googlechrome/64bit/chromedriver
            [INFO]  
            [INFO] --------------------------------------------------------
            [INFO] SELENIUM STAND-ALONE EXECUTABLE DOWNLOADS COMPLETE
            [INFO] --------------------------------------------------------
            [INFO]  
            [INFO] 
            [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ iapps-admin-portal ---
            [INFO] Surefire report directory: /var/lib/jenkins/workspace/CucumberTest-Maven/
                target/surefire-reports

            -------------------------------------------------------
             T E S T S
            -------------------------------------------------------
            Running base.RunITTest
            Customer: iapps
            Loaded Config: /var/lib/jenkins/workspace/CucumberTest-Maven/configurations/data/
                iapps-stage-data.properties
            Customer: iapps
            Loaded Config: /var/lib/jenkins/workspace/CucumberTest-Maven/configurations/elements/
                iapps-elements.properties
            Customer: iapps
            Loaded Config: /var/lib/jenkins/workspace/CucumberTest-Maven/configurations/asserts/
                iapps-asserts.properties
            Browser: chrome
            Starting ChromeDriver 2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926) on port 26512
            Only local connections are allowed.
            Please protect ports used by ChromeDriver and related test frameworks to prevent access by 
                malicious code.
            Browser: chrome
            Starting ChromeDriver 2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926) on port 25905
            Only local connections are allowed.
            Please protect ports used by ChromeDriver and related test frameworks to prevent access by 
                malicious code.
            Feature: Perform groups listing and creation

              Background:                                                                                            
                src/test/resources/features/UserManagment/Groups.feature:
                Given I open the url login.url
                PageStepDef.openUrl(String)[0m
                  cucumber.runtime.CucumberException: Failed to instantiate class base.PageStepDef
                at cucumber.runtime.java.DefaultJavaObjectFactory.cacheNewInstance
                (DefaultJavaObjectFactory.java:47)
                at cucumber.runtime.java.DefaultJavaObjectFactory.getInstance
              (DefaultJavaObjectFactory.java:33)
                at cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.java:49)
                at cucumber.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:50)
                at cucumber.runner.TestStep.executeStep(TestStep.java:63)
                at cucumber.runner.TestStep.run(TestStep.java:49)
                at cucumber.runner.PickleStepTestStep.run(PickleStepTestStep.java:43)
                at cucumber.runner.TestCase.run(TestCase.java:44)
                at cucumber.runner.Runner.runPickle(Runner.java:40)
                at cucumber.runtime.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:146)
                at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:68)
                at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:23)
                at org.junit.runners.ParentRunner.run(ParentRunner.java:290)
                at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
                at org.junit.runners.ParentRunner.access[=13=]0(ParentRunner.java:58)
                at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:268)
                at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
                at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:73)
                at cucumber.api.junit.Cucumber.runChild(Cucumber.java:124)
                at cucumber.api.junit.Cucumber.runChild(Cucumber.java:65)
                at org.junit.runners.ParentRunner.run(ParentRunner.java:290)
                at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
                at org.junit.runners.ParentRunner.access[=13=]0(ParentRunner.java:58)
                at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:268)
                at cucumber.api.junit.Cucumber.evaluate(Cucumber.java:133)
                at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
                at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
                at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet
                   (JUnit4Provider.java:141)
                at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
                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.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray
               (ReflectionUtils.java:189)
                at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.
                invoke(ProviderFactory.java:165)
                at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider
                   (ProviderFactory.java:85)
                at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess
                   (ForkedBooter.java:115)
                at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
                    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 cucumber.runtime.java.DefaultJavaObjectFactory.
                cacheNewInstance(DefaultJavaObjectFactory.java:41)
                ... 39 more
               Caused by: org.openqa.selenium.WebDriverException: unknown error: 
                Chrome failed to start: exited abnormally
              (unknown error: DevToolsActivePort file doesn't exist)
              (The process started from chrome location /usr/bin/google-chrome is no longer running, 
                so ChromeDriver is assuming that Chrome has crashed.)
              (Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),
                platform=Linux 3.10.0-1062.7.1.el7.x86_64 x86_64) (WARNING: The server did not provide 
                any stacktrace information)
                Command duration or timeout: 172 milliseconds
                Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
                System info: host: 'jenkins', ip: '192.168.1.219', os.name: 'Linux', os.arch: 'amd64', 
                os.version: '3.10.0-1062.7.1.el7.x86_64', java.version: '1.8.0_232'
                Driver info: driver.version: ChromeDriver
                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.ErrorHandler.createThrowable(ErrorHandler.java:214)
                at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
                at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new[=13=]
                (JsonWireProtocolResponse.java:53)
                at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda
                $getResponseFunction(JsonWireProtocolResponse.java:91)
                at org.openqa.selenium.remote.ProtocolHandshake.lambda$
                createSession[=13=](ProtocolHandshake.java:122)
                at java.util.stream.ReferencePipeline.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:531)
                at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:125)
                at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
                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:548)
                at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212)
                at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
                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:157)
                at base.PageStepDef.<init>(PageStepDef.java:57)
                ... 44 more
    ```

Here are the settings that I am using to build **Free Style Project** :

[Build Settings for Free Style Project in Jenkins][1]
<br>Here are the settings that I am using to build **Maven Project** :
[Build Settings for Maven Project in Jenkins][2]
<br>Here is the console output of Free Style project :
[enter image description here][3]


  [1]: https://i.stack.imgur.com/bRDnr.png
  [2]: https://i.stack.imgur.com/AknqS.png
  [3]: https://i.stack.imgur.com/FYQ1t.png

可能有多个根本原因。第一个解决方案是在脚本中添加以下代码

chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')

如果上述方法不起作用,那么您必须检查 chrome 驱动程序与 Jenkins 节点中存在的 chrome 浏览器的兼容性。

旧版本:

chromedriver    chrome
2.46            71-73
2.45            70-72
2.44            69-71
2.43            69-71
2.42            68-70
2.41            67-69
2.40            66-68
2.39            66-68
2.38            65-67
2.37            64-66
2.36            63-65
2.35            62-64
2.34            61-63
2.33            60-62
---------------------
2.28            57+
2.25            54+
2.24            53+
2.22            51+
2.19            44+
2.15            42+

对于最新的 Chrome 浏览器

If you are using Chrome version 84, please download ChromeDriver 84.0.4147.30
If you are using Chrome version 83, please download ChromeDriver 83.0.4103.39
If you are using Chrome version 81, please download ChromeDriver 81.0.4044.69
If you are using Chrome version 80, please download ChromeDriver 80.0.3987.106
If you are using Chrome version 79, please download ChromeDriver 79.0.3945.36
If you are using Chrome version 78, please download ChromeDriver 78.0.3904.105
If you are using Chrome version 77, please download ChromeDriver 77.0.3865.40
If you are using Chrome version 76, please download ChromeDriver 76.0.3809.126
If you are using Chrome version 75, please download ChromeDriver 75.0.3770.140
If you are using Chrome version 74, please download ChromeDriver 74.0.3729.6
If you are using Chrome version 73, please download ChromeDriver 73.0.3683.68

最后,如果上述解决方案不起作用,那么您可以实施 selenium 网格,然后执行测试脚本。