question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Protractor and angular manual bootstrap

See original GitHub issue

I’m having a problem when running protractor 0.8 and having troubles running protractor on our app that is manually bootstrapped.

Here are some snippets revealing the relevant parts of the application and setup: index.html:

 <script type="text/javascript" data-main="js/main" src="js/libraries/require.js"></script>

js/main.js:

require({
    shim: {
        .... snip ..
            }
           }, 
  ['require', ..... ], function(require) {
    return require(['bootstrap']);

bootstrap.js:

var appElm = $('html');
appElm.addClass('ng-app'); // this
angular.bootstrap(document, ['app']);

This works in practice and Angular is started in a correct way. When I view the html source I cannot see the ng-app attribute appearing on the html element. May be Protractor also fails to do so?

I use the protractor sample configuration and changed the relevant values to suit my app:

specs: [
    '../src/test/javascript/protractorSpec/*_spec.js',
  ],
  baseUrl: 'http://localhost:8080/Viewer/',
  rootElement: 'html',

Sample test:

describe('List SMC Charts', function() {
        var ptor= protractor.getInstance();

        beforeEach(function() {
          ptor.get('#/smcChart');
        });

        it('list, no filter', function() {
          var selectOption = ptor.findElement(ptor.By.input("selectOption"));
        });
});

When I run this test two errors appear:

 1) List SMC Charts   list, no filter
   Message:
     Error: Angular could not be found on the page http://localhost:8080/Viewer/#/smcChart
   Stacktrace:
     Error: Angular could not be found on the page http://localhost:8080/Viewer/#/smcChart
    at /usr/local/lib/node_modules/protractor/lib/protractor.js:392:15

and

2) List SMC Charts list, no filter
   Message:
     TypeError: Cannot call method 'input' of undefined
   Stacktrace:
     TypeError: Cannot call method 'input' of undefined
    at null.<anonymous> (/Users/........//Viewer/src/test/javascript/protractorSpec/some_spec.js:9:55)

The first error seems to be the most important one, but the last error is also quite interesting. It appears to me that the line: ptor.By.input is not working.

Any ideas?

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:49 (8 by maintainers)

github_iconTop GitHub Comments

9reactions
miguelrinconcommented, Feb 4, 2017

@sjelin What’s the documented way to support manual bootstrapping? I can’t find the relevant information for protractor 5.0.

6reactions
bchernycommented, May 6, 2016

@juliemr With Angular 1.5, manually bootstrapping is the preferred way to bootstrap. Is there blessed protractor support on the way?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Protractor Manually Bootstrap Angularjs - Stack Overflow
I have an Angularjs 1.6.7 app that I am trying to use Protractor 5.1.2 to run e2e tests on. It works fine if...
Read more >
angular.bootstrap - AngularJS: API
Use this function to manually start up AngularJS application. ... Note: Protractor based end-to-end tests cannot use this function to bootstrap manually.
Read more >
Protractor - end-to-end testing for AngularJS
Protractor is an end-to-end test framework for Angular and AngularJS applications. Protractor runs tests against your application running in a real browser, ...
Read more >
Bootstrapping in Angular: How It Works Internally
Bootstrapping in Angular shows how Angular works internally ... It also configures the Typescript, Webpack, Karma, & Protractor.
Read more >
How to manually bootstrap an Angular application - Medium
bootstrapModule (AppModule);. The first part of the statement platformBrowserDynamic() creates a platform. Angular docs describe the platform as: the entry point ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found