jenkins(openshift)Chrome节点

时间:2019-04-05 21:28:54

标签: maven jenkins automated-tests selenium-chromedriver openshift

我一直试图在Jenkins(服务器/ openshift)上运行硒代码。 jenkins机器中有一个用于自动测试-Selenium的chrome节点。我收到此错误:

  

org.openqa.selenium.WebDriverException:未知错误:Chrome无法启动:异常退出

测试ll可以在Chrome节点jenkins-openshift上运行。因此,除了将浏览器类型设置为无头之外,我不需要将浏览器类型设置为无头,它找不到我们应用程序的任何UI组件。顺便说一句,我使用黄瓜/小黄瓜开发了这段代码。

它通过maven clean-verify在本地工作。

这是我们的jenkins文件,用于在jenkins上运行自动化的UI测试:

    stage('scm checkout') {
        echo '****************************************\r*** scm checkout'
        checkout scm
        echo '*** show content ***'
        sh "ls -lA"
    }

    stage('build artifact') {
        echo '****************************************\r*** Build Artifact'
        sh "mvn -V -B clean package"
    }

    stage('selenium GUI test') {
            echo '****************************************\r*** Selenium GUI Test'
            sh "mvn -V -B clean verify"
        }
}

这是pom.xml的相关部分:

<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-failsafe-plugin</artifactId>
                <version>2.18.1</version>
                <executions>
                    <execution>
                        <configuration>
                            <forkCount>3</forkCount>
                            <reuseForks>true</reuseForks>
                            <encoding>UTF-8</encoding>
                            <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
                            <testFailureIgnore>true</testFailureIgnore>
                            <includes>
                                <includesFile>**/*UITestsRunner.java</includesFile>
                            </includes>
                        </configuration>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>net.masterthought</groupId>
                <artifactId>maven-cucumber-reporting</artifactId>
                <version>3.8.0</version>
                <executions>
                    <execution>
                        <id>execution</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <projectName>testing</projectName> 

                            <outputDirectory>target/cucumber-reports/advanced-reports</outputDirectory>
                            <cucumberOutput>target/cucumber-reports/CucumberTestReport.json</cucumberOutput>
                            <buildNumber>1</buildNumber>
                            <parallelTesting>false</parallelTesting>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>

此外,这是代码的网络驱动程序设置的一部分:

            ChromeOptions options = new ChromeOptions();
            options.addArguments("--no-sandbox"); //Bypass OS security model
            options.addArguments("--disable-web-security");
            options.addArguments("--ignore-urlfetcher-cert-requests");
            //options.addArguments("--disable-renderer-backgrounding");
            options.addArguments("--disable-infobars"); //Disabling infobars
            //options.addArguments("--start-maximized"); //Open Browser in maximized mode
            options.addArguments("--disable-dev-shm-usage"); //Overcome limited resource problem
            options.setExperimentalOption("useAutomationExtension", false);
            options.addArguments("--log-level=3"); // set log level
            options.addArguments("--silent");
            options.addArguments("--disable-gpu");
            options.addArguments("window-size=1920,1080");
            webDriver = new ChromeDriver(options);

在本地没有问题,但是在服务器上,我一直收到此错误:

  

org.openqa.selenium.WebDriverException:未知错误:Chrome无法启动:异常退出           (未知错误:DevToolsActivePort文件不存在)           (该进程从chrome位置/ usr / bin / google-chrome开始不再运行,因此ChromeDriver假定Chrome崩溃了。)           (驱动程序信息:chromedriver = 73.0.3683.68(47787ec04b6e38e22703e856e101e840b65afe72),平台= Linux 3.10.0-957.10.1.el7.x86_64 x86_64)(警告:服务器未提供任何堆栈跟踪信息)         命令持续时间或超时:287毫秒         内部版本信息:版本:'3.5.2',版本:'10229a9',时间:'2017-08-21T17:29:55.15Z'         系统信息:主机:'jenkins-agent-blue-1',ip:'127.0.1.1',操作系统名称:'Linux',os.arch:'amd64',os.version:'3.10.0-957.10。 1.el7.x86_64',java.version:'1.8.0_192'         驱动程序信息:driver.version:ChromeDriver           在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)处           在sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)           在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)           在java.lang.reflect.Constructor.newInstance(Constructor.java:423)           在org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)           在org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)           在org.openqa.selenium.remote.JsonWireProtocolResponse.lambda $ new $ 0(JsonWireProtocolResponse.java:53)           在org.openqa.selenium.remote.JsonWireProtocolResponse.lambda $ getResponseFunction $ 2(JsonWireProtocolResponse.java:91)           在org.openqa.selenium.remote.ProtocolHandshake.lambda $ createSession $ 24(ProtocolHandshake.java:359)           在java.util.stream.ReferencePipeline $ 3 $ 1.accept(ReferencePipeline.java:193)           在java.util.Spliterators $ ArraySpliterator.tryAdvance(Spliterators.java:958)           在java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)           在java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)           在java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)           在java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)           在java.util.stream.FindOps $ FindOp.evaluateSequential(FindOps.java:152)           在java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)           在java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)           在org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:362)           在org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:136)           在org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)           在org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)           在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:641)           在org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:254)           在org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)           在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:137)           在org.openqa.selenium.chrome.ChromeDriver。(ChromeDriver.java:178)           在org.openqa.selenium.chrome.ChromeDriver。(ChromeDriver.java:167)           在org.openqa.selenium.chrome.ChromeDriver。(ChromeDriver.java:156)

在Chrome节点(詹金斯)中,我在本地使用Chrome(版本 73 )和ChromeDriver(版本 73.0.3683.68 )。

1 个答案:

答案 0 :(得分:0)

添加options.addArguments("--remote-debugging-port=9222");