protractor的安裝與基本使用教程
前言
Protractor是一個建立在WebDriverJS基礎(chǔ)上的端到端(E2E)的AngularJS JavaScript Web應(yīng)用程序測試框架。Protractor全自動化真實的模擬用戶在真正的瀏覽器中操作、運行并測試開發(fā)者的應(yīng)用程序。下面就來一起看看關(guān)于protractor安裝與基本使用的相關(guān)內(nèi)容吧。
1、JDK的安裝和環(huán)境的配置
關(guān)于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>
總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。
相關(guān)文章
AngularJS動態(tài)生成select下拉框的方法實例
這篇文章主要給大家介紹了關(guān)于AngularJS動態(tài)生成select下拉框的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家學習或者使用AngularJS具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧2019-11-11
Angular項目中$scope.$apply()方法的使用詳解
這篇文章主要給大家介紹了關(guān)于Angular項目中$scope.$apply()方法使用的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家學習或者使用Angularjs具有一定的參考學習價值,需要的朋友們下面跟著小編一起來看看吧。2017-07-07
Angular.js如何從PHP讀取后臺數(shù)據(jù)
這篇文章主要為大家簡單介紹了Angular.js如何從PHP讀取后臺數(shù)據(jù),本文將Angular和PHP相結(jié)合,從后臺讀取數(shù)據(jù),感興趣的小伙伴們可以參考一下2016-03-03

