【发布时间】:2019-04-04 13:04:53
【问题描述】:
我对 Protractor 和 JS 还很陌生。我编写了一个简单的代码来使用在线计算器添加几个数字。添加我正在通过调用一个 add() 函数来返回一个 Promise。这个 Promise 我正在我的 it 块中处理它导致问题并给出上述错误。
尝试更新版本但没有帮助
describe("Using Protractor and working", function(){
var resultsExpected = [];
function add(a,b){
return new Promise(function(resolve, reject){
element(by.model("first")).sendKeys(String(a));
element(by.model("second")).sendKeys(String(b));
element(by.id("gobutton")).click();
var len=0;
len = resultsExpected.length;
resultsExpected[len] = {value:String(a+b)};
console.log("Length is: "+resultsExpected.length);
console.log("Item inside: "+resultsExpected[len].value);
resolve();
});
}
it("Addition from calc should give correct result", function(){
browser.get('http://juliemr.github.io/protractor-demo/');
add(2,4).then(function(ff){
expect(element(by.css("h2.ng-binding")).getText()).toEqual("6");
return add(5,3);
}).then(function(ff){
expect(element(by.css("h2.ng-binding")).getText()).toEqual("8");
return add(5,8);
}).then(function(ff){
expect(element(by.css("h2.ng-binding")).getText()).toEqual("13");
})
})
})
Failures:
1) Using Protractor and working Addition from calc should give correct result
Message:
[31m Error: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"[0m
Stack:
Error: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
at runWaitForAngularScript.then (D:\JavaScriptWorkSpace\FirstProtractor\protractor\built\browser.js:463:23)
at ManagedPromise.invokeCallback_ (D:\JavaScriptWorkSpace\FirstProtractor\protractor\node_modules\selenium-webdriver\lib\promise.js:1376:14)
at TaskQueue.execute_ (D:\JavaScriptWorkSpace\FirstProtractor\protractor\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (D:\JavaScriptWorkSpace\FirstProtractor\protractor\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at asyncRun (D:\JavaScriptWorkSpace\FirstProtractor\protractor\node_modules\selenium-webdriver\lib\promise.js:2927:27)
at D:\JavaScriptWorkSpace\FirstProtractor\protractor\node_modules\selenium-webdriver\lib\promise.js:668:7
at process._tickCallback (internal/process/next_tick.js:68:7)Error
at ElementArrayFinder.applyAction_ (D:\JavaScriptWorkSpace\FirstProtractor\protractor\built\element.js:459:27)
at ElementArrayFinder.(anonymous function).args [as getText] (D:\JavaScriptWorkSpace\FirstProtractor\protractor\built\element.js:91:29)
at ElementFinder.(anonymous function).args [as getText] (D:\JavaScriptWorkSpace\FirstProtractor\protractor\built\element.js:831:22)
at D:\JavaScriptWorkSpace\FirstProtractor\WorkinWithDropDown.js:55:45
at process._tickCallback (internal/process/next_tick.js:68:7)
【问题讨论】:
-
browser.ignoreSynchronization = true; browser.waitForAngularEnabled(false);他们都没有帮助。
标签: protractor