我想使用 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
提交
取消