【发布时间】:2019-05-06 11:31:29
【问题描述】:
我有一个网页在进入 Angular 网页之前需要 Google 身份验证,并且我已经构建了一些非常基本的端到端测试,这些测试在 Linux 中使用 Chrome Headless 就像一个魅力:
- 查找用户名字段
- 输入正确的电子邮件地址,然后单击下一步
- 输入密码登录
- 一旦通过 Google 身份验证,就会验证页面的标题是“费用”
这是我在终端中收到的最后一条消息:Executed 3 of 3 specs SUCCESS in 46 secs.
不过,在 AWS CodeBuild 中,我们也使用 Linux (Ubuntu) 容器,并且每次都会失败。
这是第一个错误:
...
茉莉花开始
- 查找用户名字段
- 输入正确的测试电子邮件 地址
已识别 0 个 h1 标签 Expense App E2E 初始测试套件 费用的索引页面应该可以正常工作
- [31m✗应该用测试用户正确登录·[39m
- [31m-··[39m·[31mFailed:使用定位器找不到元素:By(css selector, *[id="identifierId"])
- [39m at elementArrayFinder.getWebElements.then (/codebuild/output/src609592849/src/node_modules/protractor/built/element.js:814:27)
这是 protractor.conf.js 中的设置信息:
capabilities: {
'browserName': 'chrome',
chromeOptions: {
args: ["--headless", "--disable-dev-shm-usage", "--no-sandbox", "--disable-gpu", "--window-size=1280x960"]
}
},
directConnect: true, // Test scripts communicate directly with Chrome Driver, so they start up and run faster
从 package.json,我正在使用: "e2e": "ng e2e --port 4200",
从 buildspec-test.yml 中,我有以下 post_build 命令: - npm run e2e
为什么 Chrome Headless 在我的本地 Linux 问题上没有问题地在 http://localhost:4200 上找到我的网页,但是当它们都运行 Ubuntu Linux 时却无法在 AWS CodeBuild 中找到它? 本地版本:Ubuntu 18.04.1 LTS AWS CodeBuild 版本:Ubuntu Ubuntu 14.04.5 LTS (Trusty)
请告诉我,提前谢谢!
此致,
私服
【问题讨论】:
-
我也有同样的问题。使用相同的映像在本地构建容器,它工作正常,但在 AWS CodeBuild 上,它需要很长时间并且会出现“NoSuchElementError”错误。您是否能够解决您的问题?
-
我面临着完全相同的问题,到目前为止有什么解决方案吗?
-
有人找到任何可行的解决方案吗?真是令人沮丧。我的错误基本上是
Angular could not be found on the page,这没有意义,因为它是一个 SPA
标签: angular protractor e2e-testing google-chrome-headless aws-codebuild