【发布时间】:2015-09-22 14:03:55
【问题描述】:
首先:我们已经找到了一些解决问题的方法:
- 角度更新 -> 我们使用最新版本的 1.4
- waitForAngular()
- window.title
- ...
但他们从来没有工作过。
我们的设置:
我们正在开发一个版本号为 1.4.x 的 AngularJS 应用程序。 当我们尝试测试 I18n 集成时,错误出现在 E2E 测试中。 对于 I18n,我们使用 angular-translate。
exports.config =
seleniumServerJar: "./node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar"
chromeDriver: "./node_modules/protractor/selenium/chromedriver"
capabilities:
browserName: "chrome"
name: "APP_NAME Selenium"
troubleshoot: true
framework: "jasmine2"
rootElement: "body"
onPrepare: ->
global.By = global.by
browser.manage().window().maximize()
jasmineNodeOpts:
showColors: true
defaultTimeoutInterval: 30000
isVerbose: true
奇怪的是,我们只在大约 50% 的时间内得到错误。有时测试通过而没有任何错误,然后我们有时至少有 1 个测试由于此错误而失败。
describe "The language", ->
it "should be german with german URL", ->
browser.get "/de/"
expect( element( By.id("slogan") ).getText() ).toEqual "SLOGAN HERE!"
it "should be preserved when a link is clicked", ->
browser.get "/de/"
element( By.css(".get-started a") ).click()
expect( browser.getCurrentUrl() ).toEqual "http://localhost:3123/de/import"
element( By.id("option-empty-table") ).click()
expect( browser.getCurrentUrl() ).toEqual "http://localhost:3123/de/editor"
it "should have the correct translations when a link is clicked", ->
browser.get "/de/"
element( By.css(".get-started a") ).click()
expect( element( By.css("#option-empty-table a h3") ).getText() ).toEqual "SOME STRING"
我们从 Gulp 开始测试。这是 gulp 任务:
gulp.task "e2e",
"Runs all e2e tests.",
[
"run"
],
->
gulp.src E2E_FILES
.pipe protractor
configFile: "./protractor.config.coffee"
args: [
"--baseUrl"
BASEURL
]
BASEURL 变量是“http://localhost:3123”
最后但并非最不重要的是 gulp 的“运行”任务:
gulp.task "run", "Serves the App.",
[
"build"
],
->
browserSync.init
server:
baseDir: BUILD.dirs.out
index: "/statics/master.html"
middleware: [modRewrite(['!\\.\\w+$ /statics/master.html [L]'])]
open: false
port: 3123
ui:
port: 3124
weinre: 3125
logLevel: "info"
notify: false
logPrefix: "SOME_PREFIX"
有人遇到过这种奇怪的行为吗?
提前致谢!
【问题讨论】:
-
什么错误?你还没有真正解释问题是什么......
-
在标题中。我认为这很清楚,因为有些人已经遇到了这个问题。但完整的错误消息是:“失败:在页面 localhost:3123/de 上找不到 Angular:从未提供 Angular resumeBootstrap”
-
@AndrewFerrier 你有什么建议吗?
-
我还没有弄清楚这一点,但我也在使用 browserSync、ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.js 和最新的量角器……也许我们看到了一些新东西?
标签: javascript angularjs protractor angularjs-e2e e2e-testing