我有以下测试:
it('diplays the currency and description of a valid account', function () {
common.setValueForInput("CH3809000000911058770", page.inputs.css.zahlungKontoIban).then(
function () {
return element(page.buttons.empfaengerKontoValidieren).click();
})
.then(function () {
return expect(element(by.id("zahlungKontoIbanFehler")).isDisplayed())
.toBeFalsy('an error message must not be shown when the accounts are different');
})
.then(function(){
browser.pause();
expect(element(by.id("zielwaehrung")).getAttribute("innerHTML"))
.toContain('CHF', 'the currency for CH3809000000911058770 is CHF')
expect(element(by.id("empfaengerName")).getAttribute("innerHTML"))
.toContain('Test Bezeichnung 2', 'the description for CH3809000000911058770 is Test Bezeichnung 2')
})
});
它因堆栈跟踪而失败:
AccountClosing - UI009.1 account validation account validation diplays the currency and description of a valid account
Message:
Failed: Cannot read property 'findElementsOverride' of undefined
Stack:
TypeError: Cannot read property 'findElementsOverride' of undefined
at C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\lib\element.js:134:20
at goog.async.run.processWorkQueue (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:124:15)
at process._tickDomainCallback (internal/process/next_tick.js:129:7)
Error
at ElementArrayFinder.applyAction_ (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\lib\element.js:382:21)
at ElementArrayFinder.(anonymous function) [as getInnerHtml] (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\lib\element.js:78:17)
at ElementFinder.(anonymous function) [as getInnerHtml] (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\lib\element.js:711:7)
at C:\beam-app\accountClosing\ui009\e2e\accountClosing_ui009_1_e2e_test.ts:94:59
at goog.async.run.processWorkQueue (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:124:15)
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: Run it("diplays the currency and description of a valid account") in control flow
at Object.<anonymous> (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:81:14)
at attemptAsync (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1819:24)
at QueueRunner.run (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1774:9)
at QueueRunner.execute (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1762:10)
at Spec.Env.queueRunnerFactory (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:627:35)
at Spec.execute (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:353:10)
at Object.fn (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:2360:37)
at attemptAsync (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1819:24)
at QueueRunner.run (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1774:9)
at C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1801:16
From asynchronous test:
Error
at Suite.<anonymous> (C:\beam-app\accountClosing\ui009\e2e\accountClosing_ui009_1_e2e_test.ts:83:13)
at addSpecsToSuite (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:743:25)
at Env.describe (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:713:7)
at jasmineInterface.describe (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:3219:18)
at Suite.<anonymous> (C:\beam-app\accountClosing\ui009\e2e\accountClosing_ui009_1_e2e_test.ts:65:9)
at addSpecsToSuite (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:743:25)
at Env.describe (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:713:7)
at jasmineInterface.describe (C:\Users\roonm\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:3219:18)
at Suite.<anonymous> (C:\beam-app\accountClosing\ui009\e2e\accountClosing_ui009_1_e2e_test.ts:36:5)
位置线94:59是
的陈述getInnerHtml()
expect(element(page.zielwaehrung).getInnerHtml())
.toContain('CHF', 'the currency for CH3809000000911058770 is CHF')
我让browser.pause()
检查元素是否确实存在并且它们是。
此消息的含义是什么以及如何调试?
答案 0 :(得分:1)
getInnerHtml
方法。请改用getAttribute("innerHTML")
。
答案 1 :(得分:0)
错误来自过多beforeAll
次来电
我错误地认为beforeAll
适用于调用它的describe
。事实证明情况并非如此,并且当你在beforeAll
内进行5次调用并且内部有一个browser.get
时,会发现一些事情。
我通过一次调用beforeEach
替换了多个调用,现在一切正常。