为了账号安全,请及时绑定邮箱和手机立即绑定

Gitlab ci selenium 测试 docker 未连接到 RemoteWebDriver

Gitlab ci selenium 测试 docker 未连接到 RemoteWebDriver

手掌心 2023-07-13 17:33:25
我想使用 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贡献2065条经验 获得超13个赞

连接到 RemoteWebDriver 的 URL 错误。我漏掉了一个下划线。

查看完整回答
反对 回复 2023-07-13
?
翻阅古今

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). 



查看完整回答
反对 回复 2023-07-13
  • 2 回答
  • 0 关注
  • 101 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信