zoukankan      html  css  js  c++  java
  • [Protractor] Testing With Protractor Page Objects

    Protractor Page Objects are a recommended for testing your AngularJS applications. Page Objects abstract the interaction between the browser and your functional tests, resulting in much cleaner tests.

    We don't want use 'browser' and element directly in the test, so we wrap those into a page object:

    function IndexPage(){
        this.button = element(by.id('button1'));
        this.message = element(by.binding('vm.messageText'));
    
        this.getPageTitle = function(){
            return browser.getTitle();
        }
    
        this.get = function(){
            browser.get('http://127.0.0.1:8080');
        }
    
        this.clickButton = function (){
            this.button.click();
        }
    
        this.getMessageText = function (){
            return this.message.getText();
        }
    }
    
    module.exports = IndexPage;

    Then in the test, we need to call get() method beforeEach.

        var page = new IndexPage();
    
        beforeEach(function (){
            page.get();
        });

    -------------

    var IndexPage = require('./indexPage');
    
    describe('Simple page test', function() {
    
        var page = new IndexPage();
    
        beforeEach(function (){
            page.get();
        });
    
        it('Should get title of the page', function() {
    
            expect(page.getPageTitle()).toBe('E2E Testing');
        });
    
        it('should update the button text when click the button', function(){
    
                page.clickButton();
                expect(page.getMessageText()).toBe('button 1 clicked');
        })
    });
  • 相关阅读:
    第一讲 递归与循环3
    第一讲 递归与循环2
    第一讲 递归与循环1
    [转]批处理
    VBA运算符(九)
    VBA常量(八)
    VBA变量(七)
    VBA输入框(InputBox)(六)
    VBA消息框(MsgBox)(五)
    VBA宏注释(四)
  • 原文地址:https://www.cnblogs.com/Answer1215/p/4987312.html
Copyright © 2011-2022 走看看