gpt4 book ai didi

selenium - Protractor : Error while waiting for Protractor to sync with the page: "Could not find testability for element."

转载 作者:太空狗 更新时间:2023-10-29 18:33:39 26 4
gpt4 key购买 nike

我正在尝试使用 ProtractorJS 对我的 Angular 2 项目进行端到端测试。当我在控制台中运行 protractor conf.js 时,我得到:

 Failed: Error while waiting for Protractor to sync with the page: "Could not
find testability for element."

在配置文件中:

exports.config = {
seleniumAddress: "http://localhost:4444/wd/hub",
framework:"jasmine2",
capabilities: {"browserName": "chrome"},
specs: ["todo-spec.js"]
};

我的根组件:

<section>
<h1>Employee Payroll Information Directory</h1>
<employee-searchform></employee-searchform>
</section>

这是我要运行的测试:

describe('modal component', function () {
it('should output the employee and delete it from the array', function () {
browser.get('http://localhost:80/Fourth/Fourth/');
var searchField = element(by.className('.ng-valid'));
searchField.click();
searchField.sendKeys('Skye');
searchField.getText().then(function (text) {
console.log(text);
});
var employeeListItem = element(by.id('employee-list'));
});
});

这是我在 webDriver Selenium 服务器上得到的:

23:57:25.816 INFO - Done: [execute async script: try { return (function (rootSel
ector, callback) {
var el = document.querySelector(rootSelector);

try {
if (window.getAngularTestability) {
window.getAngularTestability(el).whenStable(callback);
return;
}
if (!window.angular) {
throw new Error('angular could not be found on the window');
}
if (angular.getTestability) {
angular.getTestability(el).whenStable(callback);
} else {
if (!angular.element(el).injector()) {
throw new Error('root element (' + rootSelector + ') has no injector.' +

' this may mean it is not inside ng-app.');
}
angular.element(el).injector().get('$browser').
notifyWhenNoOutstandingRequests(callback);
}
} catch (err) {
callback(err.message);
}
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [body]]
23:57:25.899 INFO - Executing: [delete session: 35adb055-eee3-419e-b3c1-461b65b4
18aa])
23:57:29.157 INFO - Done: [delete session: 35adb055-eee3-419e-b3c1-461b65b418aa]

最佳答案

您应该将 Protractor 指向包含 Angular 应用程序的元素。这可以通过设置 rootElement 来完成。在你的 Protractor 配置中:

rootElement: 'app',

关于selenium - Protractor : Error while waiting for Protractor to sync with the page: "Could not find testability for element.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38883505/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com