Protractor fails to find Angular

别说谁变了你拦得住时间么 提交于 2019-11-30 18:40:34
preeve

I'm not too sure about doing a beforeEach() within a, it() but that aside, have you tried waiting a while? Obviously by this i mean either a ptor.waitForAngular() or a ptor.wait()?

Try a ptor.sleep(10000) after your ptor.get() just to see if it is a timing thing.

Edit: also take a look at the protractor api and how wait() works:

ptor.wait(function () {
  // Return a condition. Code will continue to run once it is true      
}, 10000); // Only do this for 10 seconds

Edit: Try ptor.driver.get('my-page'); instead of ptor.get('my-page');

Edit: Protractor now exposes browser as a global so you can just use browser.get('index.html#/foo') or browser.wait() etc.

Mohammad Ibrahim Khan

Try including this in your test file:

browser.ignoreSynchronization = true;

It switches off your test's sync with angular and makes it work.

Are you using ng-app to bootstrap your Angular application? Or are you manually bootstrapping your application?

I see that in your configuration file that rootElement is set to 'html'.

By default protractor assumes that the root of the app will be on the body tag. If the <html> tag is not where angular bootstraps in your application, try changing the root element in the config file to where angular first bootstraps(wether it is manually or though using the ng-app directive). This really helps with timing issues, and speeds protractors execution up.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!