当前位置: 首页 > 知识库问答 >
问题:

JenkinsSelenium上的Firefox错误:"错误:无法打开显示"

薄烨
2023-03-14

我正在尝试使用 Selenium 在 Jenkins 上运行测试用例,但我得到“无法打开显示器”(我已经尝试过同时显示“:1”和“:99”)。

一些信息:

  • Selenium版本2.35.0
  • JDK 1.6.0_25
  • 我在Debian环境中运行
  • 我已经安装了Xvfb
  • 在代码(见下文)和jenkins/confiure全局属性(name=DISPLAY, value=: 99(或: 1))中声明了DISPLAY

我的POM:

<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <modelVersion>4.0.0</modelVersion>

    <groupId>org.squashtest.jenkins</groupId>
    <artifactId>my.squash.ta.project</artifactId>
    <packaging>pom</packaging>
    <version>1.0</version>

    <!-- Properties definition -->
    <properties>
        <!-- Squash-TA framework version used by the project -->
        <ta.framework.version>1.7.1-RELEASE</ta.framework.version>
        <!-- Log configuration file -->
        <logConfFile>src/log4j.properties</logConfFile>
    </properties>

    <build>
        <plugins>
            <!-- Configuration of the Squash TA framework used by the project -->
            <plugin>
                <groupId>org.squashtest.ta</groupId>
                <artifactId>squash-ta-maven-plugin</artifactId>
                <version>${ta.framework.version}</version>

                <dependencies>
                    <dependency>
                        <groupId>org.seleniumhq.selenium</groupId>
                        <artifactId>selenium-java</artifactId>
                        <version>2.35.0</version>
                    </dependency>  
                     <dependency>
                        <groupId>org.seleniumhq.selenium</groupId>
                        <artifactId>selenium-firefox-driver</artifactId>
                        <version>2.35.0</version>
                    </dependency>
                     <dependency>
                        <groupId>org.seleniumhq.selenium</groupId>
                        <artifactId>selenium-server</artifactId>
                        <version>2.35.0</version>
                     </dependency>  
                </dependencies>

                <!-- Under here is the Squash TA framework default configuration -->
                <configuration>

                    <!-- Uncomment the line below in order to the build finish in success even if a test failed -->
                    <!-- <alwaysSuccess>true</alwaysSuccess> -->

                    <!-- Define a log configuration file (at log4j format) to override the one defined internally -->
                    <!-- If the given file can't be found the engine switch to the internal configuration-->
                    <logConfiguration>${logConfFile}</logConfiguration>

                    <!-- Define exporters -->
                    <exporters>
                        <surefire>
                            <jenkinsAttachmentMode>${ta.jenkins.attachment.mode}</jenkinsAttachmentMode>
                        </surefire>
                        <html/>
                    </exporters>

                    <!-- Define configurers -->
                    <configurers>
                        <tmCallBack>
                            <endpointURL>${status.update.events.url}</endpointURL>
                            <executionExternalId>${squash.ta.external.id}</executionExternalId>
                            <jobName>${jobname}</jobName>
                            <hostName>${hostname}</hostName>
                            <endpointLoginConfFile>${squash.ta.conf.file}</endpointLoginConfFile>
                        </tmCallBack>
                    </configurers>
                </configuration>

                <!-- Bind the Squash TA "run" goal to the maven integration-test phase and reuse the default configuration -->
                <executions>
                    <execution>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <!-- Squash TA maven repository -->
    <repositories>
        <repository>
            <id>org.squashtest.ta.release</id>
            <name>squashtest test automation - releases</name>
            <url>http://repo.squashtest.org/maven2/releases</url>
        </repository>
    </repositories>

    <!-- Squash TA maven plugin repository -->
    <pluginRepositories>
        <pluginRepository>
            <id>org.squashtest.plugins.release</id>
            <name>squashtest.org</name>
            <url>http://repo.squashtest.org/maven2/releases</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <enabled>true</enabled>
            </releases>
        </pluginRepository>
    </pluginRepositories>

</project>

我的代码:

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import java.io.File;
import org.openqa.selenium.support.ui.Select;

public class ConnexionInterfaceFortress {

String baseUrl = "http://foobar.com";
WebDriver driver = null;
StringBuffer verificationErrors = new StringBuffer();
boolean acceptNextAlert = true;
FirefoxBinary binary = new FirefoxBinary(new File("/usr/bin/firefox"));
FirefoxProfile profile = new FirefoxProfile();

  @Before
  public void setUp() throws Exception {
  }

  @Test
  public void testConnexion() throws Exception {
try{
        binary.setEnvironmentProperty("DISPLAY",System.getProperty("lmportal.xvfb.id",":99"));
        profile.setEnableNativeEvents(true);
        driver = new FirefoxDriver(binary, profile);
        } catch (Error e) {
            System.out.println("Creation du navigateur impossible");
        }
    driver.manage().window().maximize();      
    driver.get(baseUrl); 
 }

  @After
  public void tearDown() throws Exception {
    driver.quit();
    String verificationErrorString = verificationErrors.toString();
    if (!"".equals(verificationErrorString)) {
      fail(verificationErrorString);
    }
  }

  private boolean isElementPresent(By by) {
    try {
      driver.findElement(by);
      return true;
    } catch (NoSuchElementException e) {
      return false;
    }
  }

  private String closeAlertAndGetItsText() {
    try {
      Alert alert = driver.switchTo().alert();
      if (acceptNextAlert) {
        alert.accept();
      } else {
        alert.dismiss();
      }
      return alert.getText();
    } finally {
      acceptNextAlert = true;
    }
  }
}

我的完整日志:

Started by user tmserver
Building in workspace /usr/local/bin/squashta/execution_home/jobs/Connexion 2/workspace
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url git@gitlab.rvip.fr:qa/QAJenkinsTest.git # timeout=10
Fetching upstream changes from git@gitlab.rvip.fr:qa/QAJenkinsTest.git
 > git --version # timeout=10
 > git -c core.askpass=true fetch --tags --progress git@gitlab.rvip.fr:qa/QAJenkinsTest.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 05b328fa1a5b07a9c225eee58683e6d19ef98fa1 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 05b328fa1a5b07a9c225eee58683e6d19ef98fa1
 > git rev-list 00124836ba6caebc7e9ffbd234b2fa01488c10b9 # timeout=10
provisoning config files...
copy managed file [conf.properties] to file:/usr/local/bin/squashta/execution_home/taLinkConf.properties
Copying file to testsuite.json
Parsing POMs
using global settings config with name TaGlobalSettings
Replacing all maven server entries not found in credentials list is null
[workspace] $ /usr/local/bin/squashta/openjdk1.6.0_25-unix-i586/bin/java -Xms512m -Xmx512m -XX:PermSize=256m -XX:MaxPermSize=512m -cp /usr/local/bin/squashta/execution_home/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.4.jar:/usr/local/bin/squashta/apache-maven-3.0.4/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main /usr/local/bin/squashta/apache-maven-3.0.4 /usr/local/bin/squashta/apache-tomcat-7.0.54/webapps/jenkins/WEB-INF/lib/remoting-2.33.jar /usr/local/bin/squashta/execution_home/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.4.jar /usr/local/bin/squashta/execution_home/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.4.jar 56944
<===[JENKINS REMOTING CAPACITY]===>channel started
using global settings config with name TaGlobalSettings
Replacing all maven server entries not found in credentials list is null
log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.converters.BooleanConverter).
log4j:WARN Please initialize the log4j system properly.
Executing Maven:  -B -f /usr/local/bin/squashta/execution_home/jobs/Connexion 2/workspace/pom.xml -gs /usr/local/bin/squashta/apache-tomcat-7.0.54/temp/global-settings7531672306724044985.xml -Dta.test.suite=ConnexionInterfaceFortress.ta -Dstatus.update.events.url=file://dev/null -Dsquash.ta.external.id= -Djobname=Connexion 2 -Dhostname=AWS-RND-TEST-PR -Dsquash.ta.conf.file=/usr/local/bin/squashta/execution_home/taLinkConf.properties -Dta.tmcallback.reportbaseurl=http://squashta.rvip.fr:9080/jenkins/job -Dta.tmcallback.jobexecutionid=46 -Dta.tmcallback.reportname=Squash_TA_HTML_Report -Dta.delete.json.file=true org.squashtest.ta::squash-ta-maven-plugin::run
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building my.squash.ta.project 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- squash-ta-maven-plugin:1.7.1-RELEASE:run (default-cli) @ my.squash.ta.project ---
[INFO] Loading external logging configuration: /usr/local/bin/squashta/execution_home/jobs/Connexion 2/workspace/src/log4j.properties
[INFO] Squash TA : compiling tests...
[INFO] Squash TA : initializing context...
[INFO] org.squashtest.ta.backbone.init.ComponentPackagesEnumerator - Listing sqhashTA engine component packages
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.enginecore
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.commons-component
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.filechecker
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.sahi
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.selenium
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.local.process
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.soapui
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.ftp
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.db
[INFO] org.squashtest.ta.backbone.init.ComponentManifestParser - Loading plugin configuration for: org.squashtest.ta.plugin.ssh
[WARN] org.squashtest.ta.link.SquashTMCallbackEventConfigurer - The endpoint URL is set to its default value: "file://dev/null", so the call back is not activated
[INFO] Squash TA : testing...
[INFO] org.squashtest.ta.backbone.engine.impl.EcosystemRunnerImpl - Beginning execution of ecosystem tests
[INFO] org.squashtest.ta.backbone.engine.impl.TestRunnerImpl - Beginning execution of test setup.ta
[INFO] org.squashtest.ta.backbone.engine.impl.TestRunnerImpl - Beginning execution of test ConnexionInterfaceFortress.ta
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Error: cannot open display: :99
Error: cannot open display: :99

    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:106)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:251)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:195)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:190)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
    at ConnexionInterfaceFortress.testConnexion(ConnexionInterfaceFortress.java:33)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:24)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:117)
    at org.squashtest.ta.plugin.selenium.library.StandardJUnitExecutor.apply(StandardJUnitExecutor.java:74)
    at org.squashtest.ta.plugin.selenium.commands.ExecuteJavaSeleniumTwoCommand.apply(ExecuteJavaSeleniumTwoCommand.java:80)
    at org.squashtest.ta.plugin.selenium.commands.ExecuteJavaSeleniumTwoCommand.apply(ExecuteJavaSeleniumTwoCommand.java:1)
    at org.squashtest.ta.backbone.engine.wrapper.CommandHandler.apply(CommandHandler.java:132)
    at org.squashtest.ta.backbone.engine.instructionrunner.DefaultExecuteCommandRunner.doRun(DefaultExecuteCommandRunner.java:79)
    at org.squashtest.ta.backbone.engine.instructionrunner.AbstractDefaultInstructionRunner.run(AbstractDefaultInstructionRunner.java:69)
    at org.squashtest.ta.backbone.engine.impl.TestRunnerImpl.runInstruction(TestRunnerImpl.java:190)
    at org.squashtest.ta.backbone.engine.impl.TestRunnerImpl.runInstructionList(TestRunnerImpl.java:139)
    at org.squashtest.ta.backbone.engine.impl.TestRunnerImpl.runMetaInstruction(TestRunnerImpl.java:162)
    at org.squashtest.ta.backbone.engine.impl.TestRunnerImpl.runInstructionList(TestRunnerImpl.java:137)
    at org.squashtest.ta.backbone.engine.impl.TestRunnerImpl.runPhase(TestRunnerImpl.java:127)
    at org.squashtest.ta.backbone.engine.impl.TestRunnerImpl.runTest(TestRunnerImpl.java:108)
    at org.squashtest.ta.backbone.engine.impl.EcosystemRunnerImpl.runAllTests(EcosystemRunnerImpl.java:185)
    at org.squashtest.ta.backbone.engine.impl.EcosystemRunnerImpl.run(EcosystemRunnerImpl.java:103)
    at org.squashtest.ta.backbone.engine.impl.SuiteRunnerImpl.execute(SuiteRunnerImpl.java:68)
    at org.squashtest.ta.backbone.engine.impl.EngineImpl.execute(EngineImpl.java:63)
    at org.squashtest.ta.maven.SquashTAMojo.executeImpl(SquashTAMojo.java:204)
    at org.squashtest.ta.maven.AbstractSquashTaMojo.execute(AbstractSquashTaMojo.java:209)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:117)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
    at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:178)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:134)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:69)
    at hudson.remoting.UserRequest.perform(UserRequest.java:118)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:328)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)
[ERROR] org.squashtest.ta.backbone.engine.impl.TestRunnerImpl - The execution failed in the TEST phase of the TA script 'ConnexionInterfaceFortress.ta' with the message: 'Selenium test failed. Following are the name of the tests that failed:
testConnexion(ConnexionInterfaceFortress)
testConnexion(ConnexionInterfaceFortress)
'.
[INFO] org.squashtest.ta.backbone.engine.impl.TestRunnerImpl - Beginning execution of test teardown.ta
[INFO] Exporting results
[INFO] Cleaning resources
[INFO] Squash TA : build complete.
[INFO] org.squashtest.ta.core.tools.io.TempFileUtils - All the files from /tmp/Squash_TA were properly deleted.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 53.303s
[INFO] Finished at: Thu Jan 07 11:08:27 CET 2016
[INFO] Final Memory: 24M/490M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving disabled
Waiting for Jenkins to finish collecting data[ERROR] Failed to execute goal org.squashtest.ta:squash-ta-maven-plugin:1.7.1-RELEASE:run (default-cli) on project my.squash.ta.project: Build failure : there are tests failures
[ERROR] Test statistics : 1 test runs, 0 passed, 1 tests didn't pass
[ERROR] Tests failed / crashed :
[ERROR] -----------
[ERROR] tests:
[ERROR] ==> ConnexionInterfaceFortress.ta
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

channel stopped
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at BUILD level /usr/local/bin/squashta/execution_home/jobs/Connexion 2/workspace/target/squashTA/html-reports to /usr/local/bin/squashta/execution_home/jobs/Connexion 2/builds/2016-01-07_11-07-26/htmlreports/Squash_TA_HTML_Report
[htmlpublisher] Archiving at PROJECT level /usr/local/bin/squashta/execution_home/jobs/Connexion 2/workspace/target/squashTA/test-tree to /usr/local/bin/squashta/execution_home/jobs/Connexion 2/htmlreports/Test_list
Finished: FAILURE

有人知道我做错了什么吗?

提前感谢。

共有2个答案

长孙翔
2023-03-14

原来Jenkins用户只是一个服务帐户,它无权访问任何X服务器会话,因此无法打开浏览器来完成测试。

除非您在 Xvfb 插件的帮助下以无头模式运行它,或者通过 Xvnc 插件给出的虚拟显示查看输出,否则目前似乎没有更好的方法可以在 Jenkins 构建中实现硒测试。

您可能想在此处阅读有关现有问题的更多信息。

罗飞宇
2023-03-14

首先,通过本地测试来修复您的Firefox版本和selenium版本匹配。如果您通过Jenkins和日志运行作业,您会收到错误:

Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: Error: cannot open display: :0

要解决这个问题,请看下面的步骤:

>

  • Firefox 只有在您运行 Xvfb 时才会启动,请记住 Xvfb 在虚拟内存中执行所有图形操作而不显示任何屏幕输出。按如下方式运行 Xvfb。示例:Xvfb :15 -screen 0 1024x768x16 因此,请先检查这一点,您可以通过将ps -ef添加到作业的准备步骤(shell执行)中来将此检查包含在作业中。

    即使您已经显式定义了 DISPLAY 值,但仍然有错误,那么最好的方法是在 Jenkin 作业本身中注入为环境值。在“生成环境”下

    运行您的作业,应该已修复。

  •  类似资料:
    • 问题内容: 我已经在Linux Mint上将jenkins安装为服务。我正在尝试运行以python编写的测试,并且脚本无法运行Firefox。这条线是个问题。 … self.browser = webdriver.Firefox()… 当我以詹金斯用户身份登录时,我无法运行Firefox。得到这个错误: (进程:3758):GLib-CRITICAL **:g_slice_set_config:断

    • 问题内容: 我收到这个奇怪的错误 我如何从中恢复?有任何想法吗 ? 谢谢 问题答案: 您丢失了与表1684和数据库17369相关的文件。在目录base / 17369中检查名称为1684的状态文件。 您可以确定它是哪个表: 1)获取数据库名称: 2)获取表名(连接到受影响的数据库): 可能没有更多可以做的事情了。仅从备份还原。

    • 我想在数据目录中为应用程序创建一个数据库。我试着使用 但我总是遇到以下异常:无法打开数据库文件 Logcat得出以下结果: 04-10 19:55:09.387: E/SqliteDatabase aseCpp(554):sqlite3_open_v2("/data/data/at.einkaufsliste/database/Einkaufsliste.sqlite", 我设置了权限外部存储和组

    • 我在AWS ElasticBeanstalk(64位Amazon Linux/2.9.7上运行的PHP7.3)上部署了一个Laravel应用程序。应用程序运行正常,但在少数请求中会随机抛出以下错误。 PHP致命错误:未捕获的意外值异常:无法打开流或文件“/var/app/current/storage/logs/laravel.log”:无法打开流:在/var/app/current/vendor

    • 我只是想打开eclipse开始一个android项目,但它给了我这个错误: 发生错误。请参阅日志文件 我没有见过这样的错误,一些关于其他主题的建议没有帮助,我不知道在这个长日志文件中从何开始。如果有人能帮我,我会很感激的。

    • 问题内容: 我正在尝试从命令行运行Websphere自由配置文件服务器。我正在按照这里告诉的步骤进行操作:https : //developer.ibm.com/wasdev/downloads/liberty-profile-using-non-eclipse- environments/ 我创建了名称为server1的服务器。 但是当提取完成后,我尝试使用以下命令启动服务器: 服务器抛出错误:

    • 问题内容: 我正在尝试将图像加载到pygame的窗口中,但是当我运行代码时。弹出错误 pygame.error:无法打开backround.png 我将图像与代码本身放在同一文件夹中。我为另一个脚本完成了此操作,它工作得很好。我不确定是什么问题。 我尝试关闭程序。重命名文件,仅此而已。不确定如何解决该问题。任何帮助深表感谢 就像我说的那样:我使用类似的布局来加载带有另一个文件的图像,它工作得很好,

    • 问题内容: 我正在尝试为将要用于游戏的地图做基础,但无法将图像加载到屏幕上。我尝试使用相同的字母大小写将图像的绝对文件路径发送到图像,尝试更改图像的名称,尝试加载在我制作的其他程序中可以使用的其他图像,并且尝试放置图像与脚本本身位于同一目录中。什么都没有。我查看了遇到相同问题的人的一些话题,例如为什么我的pygame图片无法加载?而且我找不到我的问题的答案。图像将不会加载。这是代码: 和错误: 我