protractor的安裝與基本使用教程
前言
Protractor是一個建立在WebDriverJS基礎(chǔ)上的端到端(E2E)的AngularJS JavaScript Web應(yīng)用程序測試框架。Protractor全自動化真實的模擬用戶在真正的瀏覽器中操作、運(yùn)行并測試開發(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的依賴項
基于第二步下載到的文件,在命令行里面進(jìn)入到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)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。
相關(guān)文章
Angularjs實現(xiàn)控制器之間通信方式實例總結(jié)
這篇文章主要介紹了Angularjs實現(xiàn)控制器之間通信方式,結(jié)合實例形式總結(jié)分析了AngularJS控制器常用通信方式及相關(guān)操作注意事項,需要的朋友可以參考下2018-03-03Angular中自定義Debounce Click指令防止重復(fù)點(diǎn)擊
本篇文章主要介紹了Angular中自定義Debounce Click指令詳解,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-07-07Angular7創(chuàng)建項目、組件、服務(wù)以及服務(wù)的使用
這篇文章主要介紹了Angular7創(chuàng)建項目、組件、服務(wù)以及服務(wù)的使用,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-02-02