简体   繁体   English

在 jasmine-protractor 函数中使用 async/await 时出错

[英]Giving error on using async/await in jasmine-protractor functions

I am doing an e2e testing on my angular site using protractor-jasmine.我正在使用 protractor-jasmine 在我的角度站点上进行 e2e 测试。 On using async functions and await for rest of the code returning promise is giving error in Jasmine-protractor.在使用异步函数并等待返回承诺的其余代码时,在 Jasmine-protractor 中出现错误。

I even included: SELENIUM_PROMISE_MANAGER: false,我什至包括: SELENIUM_PROMISE_MANAGER: false,

it('Sub-folder: Manage permission, Edit Folder name, Create Template, View Template', async ()=> {
await obj.getURL();
obj.TealoginUname.sendKeys(data.uname);
obj.TealoginPass.sendKeys(data.pass);
await obj.TealoginButton.click();
await browser.sleep(2000);
})

Console Error:控制台错误:

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"

In eclipse it's showing error on those lines where async / await are written.在 Eclipse 中,它在写入async / await那些行上显示错误。 在此处输入图片说明

I am using Page object model for dynamic elements.我正在为动态元素使用 Page 对象模型。 var obj= require("./somefile.js");

somefile.js:- somefile.js:-

function  globalVariables()
{
this.TealoginUname= element(by.model("vm.login.userid"));
this.TealoginPass= element(by.model("vm.login.password"));
this.TealoginButton= element(by.xpath("//*[@id='login-form']/form[1]/button"));

}

without importing the locators add it in your test file不导入定位器将其添加到您的测试文件中

const TealoginUname= element(by.model("vm.login.userid"));
const TealoginPass= element(by.model("vm.login.password"));
const TealoginButton= element(by.xpath("//*[@id='login-form']/form[1]/button"));

Try the below one试试下面的

it('Sub-folder: Manage permission, Edit Folder name, Create Template, View Template', async ()=> {
await broswer.get('add your url here');
await browser.waitForAngularEnabled(true); // To make protractor wait for all the http request to get compelted
await TealoginUname.sendKeys(data.uname);
await TealoginPass.sendKeys(data.pass);
await TealoginButton.click();
await browser.sleep(2000);
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用节点8 async / await和angular 6调试量角器时出错 - Error debugging protractor with node 8 async/await and angular 6 量角器和黄瓜:使用异步/等待功能超时 - Protractor and Cucumber: function timed out using async/await 使用量角器茉莉花框架无法访问Web Driver Error Chrome - Web Driver Error Chrome not reachable using protractor jasmine Framework 异步操作使量角器茉莉花框架中的测试用例失败 - async operation is failing test cases in protractor jasmine framework Protractor4.0.9 / jasmine2 / Chrome 54+:错误:超时 - 在jasmine.DEFAULT_TIMEOUT_INTERVAL指定的超时时间内未调用异步回调 - Protractor4.0.9 / jasmine2 / Chrome 54+: Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL Angular 组件上的单元测试异步/等待 jasmine 中的 function - Angular Unit Testing on a component async / await function in jasmine 使用 async/await 时返回默认值的错误处理程序 - Error handler returning default value, when using async/await 在角度2中使用async / await函数 - Using async/await function in angular 2 函数没有使用async / await以正确的顺序触发 - Functions not firing in correct order with async / await 量角器测试中的异步/等待逻辑未检测到页面元素 - Async/await logic in protractor tests doesn't detect a page element
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM