btstrpd Error when testing AngularJS app with Prot

2019-05-10 08:42发布

I’m currently trying to do some E2E testing of an AngularJS app using Protractor and I’m stuck with the btstrpd error. I'm new to AngularJS (I'm just the test automation guy in the project), so I’d really appreciate any pointers on how to make it run.

Basically I just copied and pasted the sample configuration and specification from the Protractor tutorial and adapted it for my project:

// conf.js
exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    specs: ['spec.js'],
    rootElement: 'html'
}

// spec.js
describe('Protractor Demo App', function() {

    it('should have a title', function() {
    browser.get('http://myapp.abc.de/ext/#/login');
        expect(browser.getTitle()).toEqual('My App');
    });

});

This works fine when I adapt it and run for some random AngularJS sites on the web. When running it for my current project I receive the following error:

1) Protractor Demo App should have a title
 Message:
 UnknownError: unknown error: [ng:btstrpd] http://errors.angularjs.org/1.3.15/ng/btstrpd?p0=document
  (Session info: chrome=43.0.2357.132)
  (Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 9 milliseconds

Full stacktrace here.

We use AngularJS v1.3.0 and Protractor v2.1.0. The site is auto-bootstrapped; the root element is the html tag. Could the route provider be cause this error? The configuration is as followed:

var myApp = angular.module('myApp', [ 'ngRoute' ]);

myApp.config([ '$routeProvider', function($routeProvider) {

    $routeProvider.when('/', {
        templateUrl : 'app/tmpl/start.html'
    }).when('/login', {
        templateUrl : 'app/tmpl/login.html',
        controller : 'LoginController'
    }).when('/logout', {
        templateUrl : 'app/tmpl/logout.html',
        controller : 'LogoutController'
    });
} ]);

myApp.config([ '$httpProvider', function($httpProvider) {
    $httpProvider.interceptors.push("myInterceptor");
} ]);

myApp.run([ '$rootScope', function($rootScope) {
    $rootScope.$apply(function() {
        $rootScope.tokenString = "Bearer _";
    });
} ]);

index.html:

<!doctype html>
<html ng-app="myApp"> 
<head>
    <script src="lib/jquery/jquery-2.1.1.min.js"></script>
    <script src="lib/bootstrap/js/bootstrap.js"></script>
    <script src="lib/angular/angular.min.js"></script>
    <script src="lib/angular/angular-route.min.js"></script>    

    <script src="app/app.js"></script>
    <script src="app/controller/LoginController.js"></script>
    <script src="app/controller/LogoutController.js"></script>
    <script src="app/controller/NavbarController.js"></script>
    <script src="app/services/AuthService.js"></script>
    <script src="app/services/UserService.js"></script>
    <script src="app/factories/Configurations.js"></script>
    <script src="app/factories/myInterceptor.js"></script>

    <link rel="stylesheet" href="lib/bootstrap/css/bootstrap.css">
</head>
<body>
    <nav class="navbar navbar-default" role="navigation" ng-controller="NavbarController as navbar">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed"
                    data-toggle="collapse" data-target="#navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span> <span
                        class="icon-bar"></span> <span class="icon-bar"></span> <span
                        class="icon-bar"></span>
                </button>
                <a class="navbar-brand" ng-href="navbar.root()">myApp</a>
            </div>
            <div class="collapse navbar-collapse"
                id="navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li><a ng-href="#/customers">Customers</a></li> 
                    <li ng-show="!navbar.showLogout()"><a ng-href="#/login">Login</a></li>
                    <li ng-show="navbar.showLogout()"><a ng-href="#/logout">Logout</a></li> 
                </ul>
            </div>
        </div>
    </nav>
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-12">
                <div ng-view></div>
            </div>
        </div>
    </div>
</body>
</html>

Stuff I've read in other threads and already tried, but didn't work so far:

  • Changing the framework to jasmine2
  • Use browser.driver.get in the onPrepare function
  • Use browser.waitForAngular in a beforeEach function
  • Downgrading to Protractor 1.8
  • Add an allScriptsTimeout to conf.js


EDIT: I just discovered an interesting thing. I'm able to interact with elements and execute multiple scenarios. After execution the test still fails with the btstrpd error.

1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-05-10 09:31

Following solved the problem for me

I am testing on chrome browser using selenium webdriver. I updated to latest chrome browser and I added the latest chromedriver in below folder apart from the default folder of chrome

C:\Program Files\nodejs\node_modules\protractor\node_modules\webdriver-manager\selenium

I also added zip file of chromedriver in the above folder.

I also added the chromedriver to environmental path variable.

Now the selenium webdriver is running and I am able to successfully test the project.

查看更多
登录 后发表回答