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');
        })
    });
  • 相关阅读:
    Android-setDefaultKeyMode方法
    Andorid-Fragment生命周期
    X210(s5pv210)中断系统
    X210串口配置与stdio移植
    SoC时钟系统简介
    SDRAM初始化
    重定位与链接脚本
    裸机配置C语言运行环境
    ARM汇编程序闪烁灯与其反汇编代码比较
    Makefile的简单使用
  • 原文地址:https://www.cnblogs.com/Answer1215/p/4987312.html
Copyright © 2011-2022 走看看