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

问题描述 投票:-1回答:1

我正在使用量角器 - 茉莉花在我的角度位置进行e2e测试。在使用异步函数并等待其余的代码返回promise时,在Jasmine-protractor中给出了错误。

我甚至包括: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);
})

控制台错误:

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"

在eclipse中,它显示了写入async / await的那些行的错误。 enter image description here

我正在使用Page对象模型来动态元素。 var obj= require("./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"));

}
angular eclipse async-await jasmine protractor
1个回答
0
投票

在不导入定位器的情况下将其添加到测试文件中

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"));

试试下面的一个

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);
})
© www.soinside.com 2019 - 2024. All rights reserved.