Use protractor for Angularjs e2e test Cases

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.