Download pptx - Web testing automation

Transcript
Page 1: Web testing automation

1/7

Web Testing Automation : Using Robot Framework withSelenium2Library

中 華 電 信林國瑞、凌鉅泰

2013/3/1

Page 2: Web testing automation

2

Agenda

研究動機與目的測試架構與流程測試環境安裝錄製測試個案 - Selenium IDERobot FrameworkSelenium2Library編寫測試個案 - RIDE測試個案撰寫與執行待辦工作事項Demo

Page 3: Web testing automation

3

研究動機現有測試架構流程以 Firefox 搭配 Selenium IDE錄製 Web 測試動

作利用 Selenium IDE匯出成 JUnit 測試個案擴充 JUnit 測試個案

Data Generation (Ex: BAN, IDN)Database AccessJavaScript ExecutionAssertion Extension

以 Selenium WebDriver進行測試不足之處撰寫測試個案需要一定程度的 Programming Skill測試個案不易閱讀

Page 4: Web testing automation

4

研究目的減少撰寫測試個案的複雜度與時間簡化自動化測試流程對測試人員來說 , 能單純化其測試環境

Page 5: Web testing automation

5

測試架構與流程

Page 7: Web testing automation

7

錄製測試個案 – Selenium IDE

為 Firefox extensionhttp://docs.seleniumhq.org/projects/ide/

按下 Ctrl+Alt+S 即可呼叫 IDE 錄製網頁操作

Page 8: Web testing automation

8

錄製測試個案 – Selenium IDE

測試個案可匯出為多種程式語言格式RubyPython JavaC#

不支援匯出為 Robot Framework 腳本格式(Selenium2Library)須自行撰寫擴充元件 (JavaScript) 掛載於 IDE 下

參考其他語言匯出元件 (Ex: Ruby, Java)目前已可為常用的網頁操作指令進行轉換匯出

Page 9: Web testing automation

9

錄製測試個案 – Selenium IDE

Page 10: Web testing automation

10

錄製測試個案 – Selenium IDE

掛載 Robot Framework 格式匯出元件點選 [Options] [Options] [Formats] 頁籤

Page 11: Web testing automation

11

錄製測試個案 – Selenium IDE

匯出的測試個案即可匯入 RIDE 做進一步的編輯擴充

Page 12: Web testing automation

12

Robot Framework

Sponsored by Nokia Siemens Networks以 Python 實作而成Generic Keyword-driven Test Automation測試腳本由相近於自然語言的 Keywords 敘述組成 ,

讓測試人員於撰寫與解說測試個案上更輕鬆可使用多種不同介面與軟體進行測試 , Ex: user

interfaces, command line, web services…

測試腳本檔案格式具彈性HTMLPlain TextTSV(tab-separated values)

Page 13: Web testing automation

13

Robot Framework

擴充性佳Standard Test Libraries

Builtin LibraryOperating System Library Telnet Library Collections LibraryString Library Dialogs Library Screenshot Library Remote Library XML Library

Page 14: Web testing automation

14

Robot Framework

擴充性佳External Test Libraries

Selenium2LibraryDatabaseLibrarySSHLibrary其他

也可以 Python 或 Java( 需 Jython) 撰寫自己的Test Library 定義新的 Keyword

支援迴圈與條件判斷式語法支援以 Tag 為每個 Test Case 進行分類產生美觀的測試執行結果 Report & Log

Page 15: Web testing automation

15

Robot Framework

Robot Framework 簡介 Introduction Slides

Page 16: Web testing automation

16

Selenium2Library

Web Testing Library for Robot Framework底層利用 Selenium 2 (WebDriver)

實作出豐富的網頁操作 KeywordsSelenium2Library.html

Page 17: Web testing automation

17

編寫測試個案 - RIDE

直觀的 Robot Framework 測試個案編輯器相關網址

優勢Keyword Auto CompletionView Keyword DocumentationValidate Keyword ArgumentsSearch for Keywords其他

整合 Robot Framework, 因此可以直接執行測試方便檢視測試結果 Report & Log

Page 18: Web testing automation

18

編寫測試個案 - RIDE

Page 19: Web testing automation

19

測試個案撰寫Test SuitesTest Cases 的集合並組成一個腳本檔案

測試腳本檔主要組成區塊SettingsVariablesUser-defined KeywordsTest Cases

Page 20: Web testing automation

20

測試個案撰寫Settings 區塊關鍵字Documentation – 文件說明Library – Import Test LibraryResource – Import Resource FileTest Setup/Teardown – 每個 test case 執行前

後動作Suite Setup/Teardown – 整個腳本檔執行前後動

作Tags – 為 Test Suites 加上 metadata, 在執行與

結果 Report 上進行篩選與分類Force TagsDefault Tags

Page 21: Web testing automation

21

測試個案撰寫Settings 區塊範例

Page 22: Web testing automation

22

測試個案撰寫Variables種類

Scalar Variable : ${variable_name}List Variable : @{variable_name}built-in : ${CURDIR}, ${TEMPDIR}, ${/} …

Page 23: Web testing automation

23

測試個案撰寫Keywords 種類Built-in KeywordsLibrary KeywordsUser-defined Keywords

User-defined Keywords 區塊由現有多個 keywords 再組出 higher-level

keyword可定義參數可定義回傳值可包含 FOR loops具備高度重用性抽象度變高 ,可讀性也變高

Page 24: Web testing automation

24

測試個案撰寫User-defined Keywords 區塊範例

Page 25: Web testing automation

25

測試個案撰寫Test Cases每個 Test Case 由一連串 Keyword Statements 組

成Keyword Statement 格式

[ 變數 + <分隔字元>] + keyword + <分隔字元> + 參數1 + <分隔字元> + 參數 2 + …

分隔字元須為 tab 字元 or 一個以上空格無傳回值 :

Ex: Selenium2Library.Open Browser ${baseUrl}/pac/login有傳回值 :

Ex: ${path}= Get Environment Variable path

Page 26: Web testing automation

26

測試個案撰寫Test Cases 範例

Test Cases

Page 27: Web testing automation

27

測試個案執行以 Jenkins 排程執行 Regression Test直接在 RIDE 呼叫 Robot Framework 執行測試

Page 28: Web testing automation

28

測試個案執行

Page 29: Web testing automation

29

測試個案執行Test Report(Summary)範例

Test Log(Detail)範例

Page 30: Web testing automation

30

待辦工作事項Refine Selenium IDE 匯出 Robot Framework 格式的擴充元件定義適合 FDC 環境測試的 Keywords撰寫 User Keywords撰寫 Test Library先實作 fdc-test-selenium框架原本提供的功能

網頁操作資料庫操作資料產生器Assertion 擴充

與 Jenkins 整合的部分

Page 31: Web testing automation

31

DEMO

DEMO


Recommended