Protractor E2E angular “angular could not be found on the window”

a 夏天 提交于 2019-12-09 14:16:33

问题


I have a strange error after running my tests in angular project Error: Error while waiting for Protractor to sync with the page: "angular could not be found on the window". My Protractor configuration looks like this:

require('coffee-script').register();

exports.config = {
  seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.39.0.jar',
  seleniumAddress: 'http://localhost:4444/wd/hub',

  capabilities: {
    browserName: 'chrome'
    //'chromeOptions': {
    //  'args': ['--disable-extensions']
    //}
  },

  specs: [
    '*_spec.coffee'
  ],

  allScriptsTimeout: 10000000000,
  baseUrl: 'http://localhost:9003/',

  jasmineNodeOpts: {
    isVerbose: false,
    showColors: true,
    includeStackTrace: true,
    defaultTimeoutInterval: 10000000000
  }
};

And test:

loginPage = require './pages/log_in_page'

describe 'Log In', ->

      it 'shows after login', ->
        loginPage()
        .setEmail('test@dispatch.me')
        .setPass('a46s75d4as765d4a6s7d54as76d5as74das76d5')

Get info from page:

module.exports = ->
      @email = element By.css '.test-i-login'
      @password = element By.css '.test-i-password'

      @setEmail = (name) =>
        @email.sendKeys(name)
        this

      @setPass = (number) =>
        @password.sendKeys(number)
        this
      this

There're some similar issues on github, but there I didn't find a solution working for me. Thx for answering.


回答1:


Changing framework option in Protractor config to 'jasmine2' fixed this issue for me.

See this thread for further information.




回答2:


In my scenario, login page is non angular, tried the below way, worked out for me

browser.driver.findElement(By.id('username')).sendKeys('binnu');



回答3:


Protractor is built to test Angular applications, meaning web pages that have an ng-app tag in the body of the HTML and controllers that correspond to Angular code in a Javascript file.

The reason Protractor is so useful is that Angular applications run asynchronously, meaning that they're not always finished loading when the web page loads. Most testing frameworks would try to click things, type things, etc. before the page is completely ready. Protractor detects all the Angular processes running in the background so that you don't accidentally do something before everything is ready.

What Protractor is telling you is that it didn't find any Angular processes running on the page. Your page might work fine, but it just doesn't rely on Angular in a way that Protractor can recognize.

That doesn't mean Protractor can't test the page. You can access regular WebDriver commands using browser.driver.any_webdriver_command_here(). You'll just be missing out on the fantastic synchronizing capabilities that Protractor offers.




回答4:


The reason this happened, because I had chromedriver path installation wrong. And that's why I got this message “angular could not be found on the window”. The other problem I had is that, I needed to run webdriver manually as background process. This solves by making right gulp task( which I made wrong), that'll look something like this:

gulp.task ['test'], ->
   runSequence start_server, run_protractor, end_server.

Suppose it'll help somebody, who'll have similar(silly) problems.



来源:https://stackoverflow.com/questions/28216445/protractor-e2e-angular-angular-could-not-be-found-on-the-window

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