我试图通过ci环在docker映像中运行e2e测试。
在7个测试中,有6个测试失败,而1个测试通过。 但是当我在本地运行它们时,所有测试都通过了。
这是我得到的错误
✗ Should Display Dashboard Header and Loan Information
- Failed: No element found using locator: By(css selector, h3[class="sprk-b-TypeDisplayFour sprk-o-Stack__item sprk-u-Color--white"])
at elementArrayFinder.getWebElements.then (/home/circleci/project/node_modules/protractor/built/element.js:814:27)
at ManagedPromise.invokeCallback_ (/home/circleci/project/node_modules/selenium-webdriver/lib/promise.js:1376:14)
at TaskQueue.execute_ (/home/circleci/project/node_modules/selenium-webdriver/lib/promise.js:3084:14)
at TaskQueue.executeNext_ (/home/circleci/project/node_modules/selenium-webdriver/lib/promise.js:3067:27)
at asyncRun (/home/circleci/project/node_modules/selenium-webdriver/lib/promise.js:2927:27)
at /home/circleci/project/node_modules/selenium-webdriver/lib/promise.js:668:7
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)Error
at ElementArrayFinder.applyAction_ (/home/circleci/project/node_modules/protractor/built/element.js:459:27)
at ElementArrayFinder.(anonymous function).args [as getText] (/home/circleci/project/node_modules/protractor/built/element.js:91:29)
at ElementFinder.(anonymous function).args [as getText] (/home/circleci/project/node_modules/protractor/built/element.js:831:22)
at Dashboard.getDashboardHeaderText (/home/circleci/project/e2e/app/loan/dashboard/dashboard.po.ts:47:41)
at Object.<anonymous> (/home/circleci/project/e2e/app/loan/dashboard/dashboard.e2e-spec.ts:18:30)
at step (/home/circleci/project/node_modules/tslib/tslib.js:133:27)
at Object.next (/home/circleci/project/node_modules/tslib/tslib.js:114:57)
at /home/circleci/project/node_modules/tslib/tslib.js:107:75
at new Promise (<anonymous>)
at Object.__awaiter (/home/circleci/project/node_modules/tslib/tslib.js:103:16)
From: Task: Run it("Should Display Dashboard Header and Loan Information") in control flow
at UserContext.<anonymous> (/home/circleci/project/node_modules/jasminewd2/index.js:94:19)
at
所有其他测试也都失败了,找不到相同的错误元素。
答案 0 :(得分:0)
有可能在容器尚未准备就绪时执行测试。干净的解决方案是在映像中实现HEALTHCHECK命令,并在执行测试之前等待健康状态。较简单的解决方案是启动容器,进入睡眠状态(几秒钟就足够了),然后执行测试。