• [Protractor] Test Simple Binding With Protractor


    Protractor is built to interact with AngularJS applications. In this lesson, we will take a look at how Protractor interacts with the application using its element and finder functions.

    The index.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>E2E Testing</title>
        <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
    </head>
    <body ng-app="app">
        <div ng-controller="AppCtrl as vm">
            <div class="row text-center">
                <a class="btn btn-primary"
                   id="button1"
                   ng-click="vm.updateMessageText('button 1 clicked')">
                    Button 1
                </a>
            </div>
    
            <div class="row h3 text-center">{{ vm.messageText }}</div>
        </div>
        <script src="node_modules/jquery/dist/jquery.min.js"></script>
        <script src="node_modules/angular/angular.min.js"></script>
        <script src="app.js"></script>
    </body>
    </html>

    app.js:

    angular.module('app', [])
    
        .controller('AppCtrl', function (){
            var vm = this;
    
            vm.updateMessageText = function (text){
                vm.messageText = text;
            }
        });

    index.spec.js:

    describe('Simple page test', function() {
        it('Should get title of the page', function() {
            browser.get('http://127.0.0.1:8080');
            expect(browser.getTitle()).toBe('E2E Testing');
        });
    
        it('should update the button text when click the button', function(){
            var button = element(by.id('button1')),
                message = element(by.binding('vm.messageText'));
    
                button.click();
    
                expect(message.getText()).toBe('button 1 clicked');
        })
    });

    RUN:

    webdriver-manager start
    
    protractor protractor.conf.js
  • 相关阅读:
    openresty
    ATS 相关
    pandas
    flask
    ansible
    zipline
    bcolz
    数据分析 --- concat
    Go --- 基础使用
    Go --- 基础介绍
  • 原文地址:https://www.cnblogs.com/Answer1215/p/4987308.html
Copyright © 2020-2023  润新知