發表文章

目前顯示的是有「webtest」標籤的文章

Protractor Chrome v53後的錯誤修正

   更新到Chrome 53後,原本可以正常執行測試的的Protractor出現了些bug... 無法使用鍵盤的Tab鍵。 無法執行測試,錯誤訊息"Error  Runtime.executionContextCreated has invalid 'context'"   解決方式 在github Issue 找到的解答是將selenium chrome driver 更新到2.24,不過要透過指定版本的方式,才可以更析,個人更新步驟如下: 開啟工作管理員,先將殘留chrome.exe停掉,否則無法更新driver 重新安裝 Protractor (非必要步驟,只是我因更新driver後,也無法執行測試,所以用重新安裝的方式就可以了) npm uninstall protractor -g npm install protractor –g 更新driver webdriver-manager update --standalone true --versions.chrome 2.24   參考來源 https://github.com/angular/protractor/issues/3530 https://github.com/angular/webdriver-manager/issues/93

[AngularJs] Protractor-Page Object 實作

圖片
  一開始在撰寫測試腳本並不會去考慮reuse這件事,但隨著測試腳本開始變多、變複雜時,就會看到要測同一支程式,但相同的語法散落在不同的腳本。例:a-spec.js與b-spec.js有一大段是輸入表單值的部份。幸好根據此問題,在網路有蠻多篇介紹使用Page Object Pattern的撰寫方式來解決。本文會介紹如何在Visual Studio 2013 如何實作此Pattern。 開發工具設定 Visual Studio的TypeScript Module System需要設定為CommonJs,此為NodeJs載入模組設定

[AngularJs] Protractor實用套件整理

圖片
這陣子在Survery前端e2e測試的一些撰寫方式及輔助套件,將一些實用的記錄下來,以便日後查詢。 開發及測試環境 使用NodeJS作測試 Visual Studio 2013+TypeScript撰寫測試Script   Visual Studio 套件 新增一個Web 空專案 安裝protractor的TypeScript套件 angular-protractor: browser、element、by.model、by.binding 等語法支援 jasmine : BDD測試Script,例: descript( """) it(“’….”) NodeJS套件 執行NodeJs Commad,並切換到專案目錄,執行npm init 初始化package.json,過程會要你輸入相關資訊,按照預設值可以一路按enter,此檔案會建立專案資訊及記錄相依套件 。 npm init 安裝測試套件protractor npm install -g protractor 更新webdriver webdriver-manager update 安裝jasmine-reporters,此套件可以幫助你將測試結果輸出到目錄 npm install jasmine-reporters --save-dev 建立Protractor 組態設定 protractor 參考 , jasmine-reporters 參考 撰寫測試程式 1.直接引用官方範例,在spec目錄下新增caculator-spec.ts的TypeScript檔案 2.執行測試 protractor protractor-conf.js 執行後會啟用chrome瀏覽到測試網頁,並輸入1跟2後送出,再驗證結果是否相符 3.測試結果 輸出到目錄的xml檔案 範例下載: Github 相關參考 http://ramonvictor.github.io/protractor/slides/#/ https://angular.github.io/protractor/#/tutorial https://github.com/lar...

[AngularJs] 使用Protractor作前端測試-入門

圖片
    前陣子去Techday時聽這堂課時" DEV 204 使用 AngularJS 在 ASP.NET 專案上開發企業水準的應用 ” ,講師有提到使用Protractor來作前端的單元測試,但他沒介紹如何使用….=.=,為了一解心中疑惑,Survey相關教學後,將相關使用環境、方式整理如下: 什麼是Protractor   它是AngularJs專門用來作前端測試的工具,透過nodejs上的selectium,執行chrome、fiirefox、IE等瀏覽器,來模擬使用者操作行為並驗證你撰寫好的AngularJs程式是否正確。   執行環境 AngularJs: 測試的網頁一定要內含AngularJs,否則會出現沒有Angular的錯誤 ,修正:可以使用browser.driver來撰寫 Java Runtime:selectium的執行環境 http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html NodeJs:Protractor的執行環境 撰寫測試程式 index.html 此檔案會用來測試回應的title index.spec.js 單元測試 程式,如下為使用browser物件執行index.html並取回title作比對是否為預期值 ps:最外頭的describe為描述測試方法的內容 protractor.conf.js 單元測試程式的 定義檔 ,1.baseUrl:指定測試的Url,2.specs指定要測試哪些檔案,如下圖指定spec目錄下所有副檔名為.spec.js的檔案   套件安裝 執行nodejs command prompt 1.protractor安裝 npm install -g protractor 2.webdriver更新 selectium webdriver-manager update ps:for chrome v54的driver 更新 webdriver-manager update --standalone true --versions.chrome ...