Now that the test is prepared, we can start running the Protractor test through the standalone Selenium Server. Here are the steps to run the Protractor test:
Add the test file to the Protractor configuration:
specs: ['scenario.js'],
Create an empty HTML page that will be used to make the test run:
<!DOCTYPE html> <html> <head> <title></title> </head> <body> </body> </html>
Add the index page to the Protractor configuration:
specs: ['scenario.js','index.html'],
Run the test:
$ ./node-modules/protractor/bin/protractor conf.js
The first error is Angular could not be found on the page http://localhost:8080/index.html : retries looking for angular exceeded. To rectify this, perform the following steps:
AngularJS has not been added to the page. Install
angular
throughbower
:$ bower install angular
Add the AngularJS reference to the
index.html
page:<script type="text/javascript" src="bower_components/angular/angular.js"></script>
Rerun the test.
The next error is Angular could not be found on the page http://localhost:8080/index.html : angular never provided resumeBootstrap. This error means that AngularJS couldn't load the main module of your application. To rectify this, perform the following steps:
Add a simple module into the
body
tag:<body ng-app='test'>
Initialize the module in the last tag:
<script type="text/javascript" src="bower_components/angular/angular.js"></script> <script type="text/javascript"> angular.module('test',[]); </script>
Rerun the test.
The next error has hit the expectation: Expected 'http://localhost:8080/index.html' to be 'seleniumTestTitle'. Here are the steps to rectify this error:
Set the title of the web page to the expectation:
<title>seleniumTestTitle</title>
Rerun the test.
The Protractor output now reports 1 test, 1 assertion, 0 failures. With the success of the test, we have now successfully shown you how to use the Selenium standalone server.