3

This is my refenceConf.js file i gave the testapp_spec,js in specs i gave both of them at same place

exports.config = {
  seleniumServerJar: './selenium/selenium-server-standalone-2.35.0.jar',
  seleniumPort: null,

  chromeDriver: './selenium/chromedriver',

  seleniumArgs: [],

  sauceUser: null,
  sauceKey: null,

  seleniumAddress: null,

  specs: [
    'testapp_spec.js'
  ],

  capabilities: {
    'browserName': 'chrome'
  },

  baseUrl: 'http://localhost:8000',

  rootElement: 'body',

  onPrepare: function() {

  },

  jasmineNodeOpts: {

    onComplete: null,

    isVerbose: false,

    showColors: true,

    includeStackTrace: true,

    defaultTimeoutInterval: 30000
  }
};

and this is my testapp_spec.js and i am writing a single test case to display home page

var util = require('util');

describe('longer example', function() {
  var ptor = protractor.getInstance();
  beforeEach(function() {
    ptor.get('../testapp/app/index.html')
  })

  it('should load the home page', function() {
    body = ptor.findElement(protractor.By.tagName('body'));
    body.isDisplayed().then(function() {
      expect(body).toBeDefined()
    })
  })
})

when i execute this i am getting an error like angular is not defined help me to get out from this error

3
  • Is there any experts in protractor e2e testing?????????? Commented Sep 30, 2013 at 7:01
  • +1 here. I've got the same problem. I followed the examples found on protractor's github page, as well as the in the video found here: link, but I haven't had any luck getting it to actually run my tests. The selenium server starts fine, and navigates to my site's main page but then dies when it tries to access angular saying UnknownError: javascript error: angular is not defined. If anyone has any ideas, that would be much appreciated. Commented Oct 2, 2013 at 19:57
  • I've logged a similar issue here: stackoverflow.com/questions/19391813/… and am at about the same place as you. So far, support for protractor seems to be strictly on SO, and even then not very many people know the answers. Commented Oct 15, 2013 at 22:47

5 Answers 5

2
browser.driver.get('../testapp/app/index.html')
browser.driver.findElement() 
Sign up to request clarification or add additional context in comments.

Comments

1

Did you try updating selenium port number in the configuration file? It was recommend in this video - http://www.youtube.com/watch?v=idb6hOxlyb8

This works for me (assuming that you are taking the relative path into account and executing tests from there) -

// A reference configuration file.

exports.config = {
  seleniumServerJar: './selenium/selenium-server-standalone-2.35.0.jar',
  seleniumPort: 4444,
  chromeDriver: './selenium/chromedriver',

  capabilities: {
    'browserName': 'chrome'
  },

  specs: ['./spec/*_spec.js'],

  jasmineNodeOpts: {
    onComplete: null,
    isVerbose: true,
    showColors: true,
    includeStackTrace: false,
    defaultTimeoutInterval: 30000
  }
};

1 Comment

The problem isn't the ports. The Angular app loads correctly and runs, but Protractor doesn't seem to know that it is there.
0

This is because the project for which you have written tests is not angular. Add this after declaring your protractor instance

var driver =  ptor.driver;

with this you can help protractor understand that you page is non-angular and you are using webdriver instance to find elements etc.

Hope this helps.

Comments

0

Try ptor.driver.get instead of ptor.get.

Comments

0

make sure you include the angular js libraries in your script tag inside /testapp/app/index.html. and define yout body as

 <body ng-app="angularAppDemo">

write a script inside index.html like this...

var app=angular.module('angularAppDemo',[]);

If it works, then tell me. The problem is that the protractor by default looks for angular app. as you have not mentioned any libraries of angular js, it throws this error. To test non-angular js apps and gain more knowledge about protractor. refer this link

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.