Jenkins-黄瓜测试集成-无法实例化类库。StepDef

时间:2020-06-11 20:21:14

标签: java maven jenkins cucumber

我已经在系统上成功运行Cucumber测试。我编写的测试在Bitbucket中进行管理。我的新任务包括将Jenkins与我们的Cucumber测试集成。我通过遵循在线提供的一些教程并在stackoverflow上经历了许多相关问题来尝试了这一点。几乎所有这些教程都适用于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上,我已经尝试了自由风格项目 Maven项目,但是它们都没有起作用。 我注意到的一个区别是在本地系统上,Chrome驱动程序版本为83.0.4103.39,而Jenkins使用的是ChromeDriver 2.46.628388。但我不确定是否也需要针对Jenkin的工作更新此Chrome驱动程序。如果可以,怎么办?谁能帮忙解决这个问题?

我的目标是无头运行测试,希望对此有解决方案。

这是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 Project的控制台输出(看起来与上面类似):



         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$3.run(ParentRunner.java:290)
                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
                at org.junit.runners.ParentRunner$2.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$3.run(ParentRunner.java:290)
                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
                at cucumber.api.junit.Cucumber$1.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$0
                (JsonWireProtocolResponse.java:53)
                at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda
                $getResponseFunction$2(JsonWireProtocolResponse.java:91)
                at org.openqa.selenium.remote.ProtocolHandshake.lambda$
                createSession$0(ProtocolHandshake.java:122)
                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: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

1 个答案:

答案 0 :(得分:1)

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

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

如果上述方法不起作用,则必须检查chromedriver与Jenkins Node中存在的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网格,然后执行测试脚本。

相关问题