我想使用 gitlab-ci、docker 自动运行硒测试。本地一切正常,但 docker 和 selenium 似乎存在一些连接问题。工作失败了selenium.test.dashboard.MyTest > myFirstTest FAILED org.openqa.selenium.remote.UnreachableBrowserException Caused by: java.net.ConnectException Caused by: java.net.ConnectException java.lang.NullPointerException我尝试更改不同的网址来连接到 selenium 服务器,我认为可能存在端口问题。但我尝试的每一个组合都得到了相同的结果。.gitlab-ci.ymlimage: gradle:alpinevariables: GRADLE_OPTS: "-Dorg.gradle.daemon=false"before_script: - export GRADLE_USER_HOME=`pwd`/.gradlestages: - build - seleniumTestingbuild: stage: build script: - echo $CI_JOB_STAGE - echo $CI_COMMIT_REF_NAME - gradle --build-cache war artifacts: paths: - public cache: key: "$CI_COMMIT_REF_NAME" policy: push paths: - build - .gradleseleniumTestingChrome: stage: seleniumTesting script: gradle integrationTest# services:# - selenium/standalone-chrome:latest services: - name: selenium/standalone-chrome:latest artifacts: paths: - build/reports/tests/ cache: key: "$CI_COMMIT_REF_NAME" policy: push paths: - build - .gradleRemoteWebDriver 的 Java 代码DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName()); try {// driver = new RemoteWebDriver( new URL("http://selenium_standalone-chrome:4444/wd/hub"), capabilities); WebDriver driver = new RemoteWebDriver( new URL("http://127.0.0.1:4444/wd/hub"), capabilities); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); }在运行器上创建容器
2 回答
翻阅古今
TA贡献1780条经验 获得超5个赞
gitlab https://docs.gitlab.com/ee/ci/services/#accessing-the-services中有一个主题,其中指出
Everything after the colon (:) is stripped.
Slash (/) is replaced with double underscores (__) and the primary alias is created.
Slash (/) is replaced with a single dash (-) and the secondary alias is created (requires GitLab Runner v1.1.0 or higher).
添加回答
举报
0/150
提交
取消