Environment:
[Email protected]:karma-t01$ protractor--3.0. 0 [email Protected]:karma-t01$ node-vv4. 2.2 [Email Protected]:karma
[Email protected]:karma-t01$ webdriver-Manager update[email protected]:karma-t01$ webdriver-manager start
Install Http-server:
Install -G http-server[email protected]:karma-t01$ http-server- p 8080
Browser: Chrome version 46.0.2490.86 (64-bit)
Directory structure:
2 . ├──client│├──app│├──bower_components│└──bower.json├──e2e│└──todo├──karma.conf.js├──protractor.con F.js└──readme
(1) E2e/todo/todo.spec.js
' use strict ';d escribe (',function() { Beforeeach ()} (function() { Browser.get ('/client/app/todo/todo.html '); }); It (',function() { in list ')); Expect (Todolistitems.count ()). ToBe (3); } );
(2) Client/app/todo/todo.js
= angular.module (' Application ', []); App.controller (' Todoctrl ',function($scope) { $scope. List = [' user1 ', ' user2 ', ' User3 '];});
(3) client/app/todo/todo.html
<!DOCTYPE HTML><HTML><HeadLang= "en"> <MetaCharSet= "UTF-8"> <title></title></Head><BodyNg-app= "Application"> <DivNg-controller= "Todoctrl"> <ulng-repeat= "Item in List"> <Li>{{Item}}</Li> </ul> </Div> <Scriptsrc=".. /.. /bower_components/angular/angular.js "></Script> <Scriptsrc= "Todo.js"></Script></Body></HTML>
(4) Protractor.conf.js
' Use strict '= { 110000, ' http://localhost:8080 ', true , specs: [ ' e2e/**/*.spec.js ' ], exclude: [], capabilities: { ' Browsername ': ' Chrome ' }, ' Jasmine ', jasminenodeopts: { 30000 }};
To test:
(1) Start Webdriver Build test Project
[Email protected]:karma-t01$ webdriver-27021: £58.939 INFO- Launching a standalone Selenium Server
(2) Start the HTTP service
8080 starting up HTTP-server, serving./Available on: http:127.0. 0.1:8080 http:192.168. 0.177:8080hitCTRL-C to stop the server
(3) Run the test script
[Email protected]:karma-1 instances of Webdriverselenium Standalone server started at http: c3>//192.168.0.177:47286/wd/hubStarted. 1 0 in1.207 0 instance (s) of Webdriver still running[launcher] Chrome #1 passed
Use protractor for Angularjs e2e test Cases