protractor安裝和基本使用


1 jdk 的安裝和環境的配置,自行百度

 

2 npm protractor

npm install -g protractor

 

3 npm install protractor的依賴項

基於第二步下載到的文件,在命令行里面進入到nodejs ->protractor的目錄

npm install

 

4 test工程

包括一個簡單的angular的頁面,一個配置文件和一個測試文件

配置文件protractor_conf.js代碼:

/**
 * Created by Administrator on 2015/4/24.
 */
exports.config = {
    directConnect: true,

    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        'browserName': 'chrome'
    },

    // Spec patterns are relative to the current working directly when
    // protractor is called.
    specs: ['test.js'],

    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000
    }
};

test.js文件代碼

/**
 * Created by Administrator on 2015/4/24.
 */
describe('angularjs homepage', function () {
    it('should greet the named user', function () {
        browser.get('http://localhost:63342/protractor/Index.html');
        element(by.id('userName')).sendKeys(' Sparrow');
        browser.sleep(4000);
    });
});

Index.html的代碼

<!DOCTYPE html>
<html data-ng-app="protractor">
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<div data-ng-controller="myAppController">
    {{userName}}
    <input id="userName" data-ng-model="userName" />
</div>
</body>
<script src="lib/angular.min.js"></script>
<script>
    var app = angular.module('protractor',[]);
    app.controller('myAppController',['$scope',function($scope){
        $scope.userName = 'Jackey';
    }]);
</script>

</html>

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM