2016-11-24 44 views
2

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罰款,然後開始做着陸page.spec.js在其中加載我的web應用程序,然後失敗,出現此錯誤:

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 

什麼是錯誤的原因?

回答

3

您的頁面是否構建在Angular 2中?在這種情況下,添加以下到您的config.js:

useAllAngular2AppRoots: true 

瀏覽器現在將等待所有angular2被加載。

1

添加useAllAngular2AppRoots:真,在protractor.conf.js
和它的工作對我來說