找不到元素的可测试性 - 量角器

Could not find testability for element - Protractor

config.js:

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['todo-spec.js', 'landing-page-spec.js']
};

着陆-page.spec.js:

describe('homepage', function() {
  it('navigates to the find page when clicking "try now"', function() {
    browser.get('http://localhost:3002');
    element(by.css('button.x-button')).click();
    var x = element(by.css('h2:first-of-type'));
    expect(x.getText()).toEqual("hello world");
  });
});

当我 运行 配置文件时,它通过 todo-spec.js 正常,然后它开始执行 landing-page.spec.js 加载我的网络应用程序然后失败出现此错误:

Failures: 1) VEPO homepage navigates to the find page when clicking "try now"   Message:
    Failed: Error while waiting for Protractor to sync with the page: "Could not find testability for element."   Stack:
    Error: Error while waiting for Protractor to sync with the page: "Could not find testability for element."
        at /usr/local/lib/node_modules/protractor/built/browser.js:269:23
        at ManagedPromise.invokeCallback_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1379:14)
        at TaskQueue.execute_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
        at TaskQueue.executeNext_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
        at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2775:27
        at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
        at process._tickCallback (node.js:382:9)Error
        at ElementArrayFinder.applyAction_ (/usr/local/lib/node_modules/protractor/built/element.js:397:27)
        at ElementArrayFinder._this.(anonymous function) [as click] (/usr/local/lib/node_modules/protractor/built/element.js:100:30)
        at ElementFinder.(anonymous function) [as click] (/usr/local/lib/node_modules/protractor/built/element.js:728:22)
        at Object.<anonymous> (/Users/Ben/Development/vepo/app/test/landing-page-spec.js:4:43)
        at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:94:23
        at new ManagedPromise (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1082:7)
        at controlFlowExecute (/usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:80:18)
        at TaskQueue.execute_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
        at TaskQueue.executeNext_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
        at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2820:25
    From: Task: Run it("navigates to the find page when clicking "try now"") in control flow
        at Object.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:79:14)
    From asynchronous test: 
    Error
        at Suite.<anonymous> (/Users/Ben/Development/vepo/app/test/landing-page-spec.js:2:3)
        at Object.<anonymous> (/Users/Ben/Development/vepo/app/test/landing-page-spec.js:1:1)
        at Module._compile (module.js:398:26)
        at Object.Module._extensions..js (module.js:405:10)
        at Module.load (module.js:344:32)
        at Function.Module._load (module.js:301:12)

2 specs, 1 failure Finished in 9.143 seconds [21:11:17] I/launcher - 0 instance(s) of WebDriver still running [21:11:17] I/launcher - chrome
#01 failed 1 test(s) [21:11:17] I/launcher - overall: 1 failed spec(s) [21:11:17] E/launcher - Process exited with error code 1

错误的原因是什么?

您的页面是在 Angular 2 中构建的吗?在这种情况下,将以下内容添加到您的 config.js:

useAllAngular2AppRoots: true

浏览器现在将等待所有 angular2 加载。

添加了useAllAngular2AppRoots: true,
在 protractor.conf.js 它对我有用