SlideShare une entreprise Scribd logo
1  sur  31
Web Testing Automation :
    Using Robot Framework with
    Selenium2Library
            中華電信
           林國瑞、凌鉅泰
             2013/3/1




                                 1/7
Agenda
研究動機與目的
測試架構與流程
測試環境安裝
錄製測試個案 - Selenium IDE
Robot Framework
Selenium2Library
編寫測試個案 - RIDE
測試個案撰寫與執行
待辦工作事項
Demo
                        2
研究動機
現有測試架構流程
 以Firefox搭配Selenium IDE錄製Web測試動作
 利用Selenium IDE匯出成JUnit測試個案
 擴充JUnit測試個案
   Data Generation (Ex: BAN, IDN)
   Database Access
   JavaScript Execution
   Assertion Extension
 以Selenium WebDriver進行測試
不足之處
 撰寫測試個案需要一定程度的Programming Skill
 測試個案不易閱讀
                                     3
研究目的
減少撰寫測試個案的複雜度與時間
簡化自動化測試流程
對測試人員來說,能單純化其測試環境




                    4
測試架構與流程




          5
測試環境安裝
Prerequisites
 Python v2.7.3
 Oracle Instant Client
 WebDriver
    Internet Explorer WebDriver
    Chrome WebDriver
Selenium IDE
Robot Framework v2.7.6
 Selenium2Library
 Database Library v0.5
 Oracle DB API 2.0 Drivers (Oracle 11g, Python 2.7)
RIDE v1.1
                                                       6
錄製測試個案 – Selenium IDE

為Firefox extension
 http://docs.seleniumhq.org/projects/ide/
按下 Ctrl+Alt+S 即可呼叫IDE錄製網頁操作




                                             7
錄製測試個案 – Selenium IDE

測試個案可匯出為多種程式語言格式
 Ruby
 Python
 Java
 C#
不支援匯出為Robot Framework腳本格式
(Selenium2Library)
 須自行撰寫擴充元件(JavaScript)掛載於IDE下
   參考其他語言匯出元件(Ex: Ruby, Java)
   目前已可為常用的網頁操作指令進行轉換匯出


                                 8
錄製測試個案 – Selenium IDE




                        9
錄製測試個案 – Selenium IDE

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




                                          10
錄製測試個案 – Selenium IDE

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




                           11
Robot Framework
Sponsored by Nokia Siemens Networks
以Python實作而成
Generic Keyword-driven Test Automation
 測試腳本由相近於自然語言的Keywords敘述組成,讓測
  試人員於撰寫與解說測試個案上更輕鬆
 可使用多種不同介面與軟體進行測試, Ex: user
  interfaces, command line, web services…
測試腳本檔案格式具彈性
 HTML
 Plain Text
 TSV(tab-separated values)

                                         12
Robot Framework
擴充性佳
 Standard Test Libraries
    Builtin Library
    Operating System Library
    Telnet Library
    Collections Library
    String Library
    Dialogs Library
    Screenshot Library
    Remote Library
    XML Library




                                13
Robot Framework
擴充性佳
 External Test Libraries
    Selenium2Library
    DatabaseLibrary
    SSHLibrary
    其他
 也可以Python或Java(需Jython)撰寫自己的Test
  Library定義新的Keyword
支援迴圈與條件判斷式語法
支援以Tag為每個Test Case進行分類
產生美觀的測試執行結果Report & Log

                                     14
Robot Framework
Robot Framework簡介
 Introduction Slides




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


實作出豐富的網頁操作Keywords
 Selenium2Library.html




                                          16
編寫測試個案 - RIDE
直觀的Robot Framework測試個案編輯器
 相關網址
優勢
 Keyword Auto Completion
 View Keyword Documentation
 Validate Keyword Arguments
 Search for Keywords
 其他
整合Robot Framework,因此可以直接執行測試
方便檢視測試結果Report & Log

                               17
編寫測試個案 - RIDE




                18
測試個案撰寫
Test Suites
 Test Cases的集合並組成一個腳本檔案
測試腳本檔主要組成區塊
 Settings
 Variables
 User-defined Keywords
 Test Cases




                           19
測試個案撰寫
Settings 區塊關鍵字
 Documentation – 文件說明
 Library – Import Test Library
 Resource – Import Resource File
 Test Setup/Teardown – 每個test case執行前後動作
 Suite Setup/Teardown – 整個腳本檔執行前後動作
 Tags – 為Test Suites加上metadata,在執行與結果
  Report上進行篩選與分類
   Force Tags
   Default Tags



                                            20
測試個案撰寫
Settings區塊範例




                  21
測試個案撰寫
Variables
 種類
   Scalar Variable : ${variable_name}
   List Variable : @{variable_name}
   built-in : ${CURDIR}, ${TEMPDIR}, ${/} …




                                               22
測試個案撰寫
Keywords種類
 Built-in Keywords
 Library Keywords
 User-defined Keywords
User-defined Keywords區塊
 由現有多個keywords再組出higher-level keyword
   可定義參數
   可定義回傳值
   可包含FOR loops
   具備高度重用性
   抽象度變高,可讀性也變高

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




                            24
測試個案撰寫
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




                                                             25
測試個案撰寫
Test Cases範例




               Test Cases




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




                               27
測試個案執行




         28
測試個案執行
Test Report(Summary)
 範例
Test Log(Detail)
 範例




                       29
待辦工作事項
Refine Selenium IDE匯出Robot Framework格式
的擴充元件
定義適合FDC環境測試的Keywords
 撰寫User Keywords
 撰寫Test Library
 先實作fdc-test-selenium框架原本提供的功能
   網頁操作
   資料庫操作
   資料產生器
   Assertion 擴充
與Jenkins整合的部分

                                     30
DEMO

DEMO


              31

Contenu connexe

En vedette

Acceptance Test Driven Development using Robot Framework
Acceptance Test Driven Development using Robot FrameworkAcceptance Test Driven Development using Robot Framework
Acceptance Test Driven Development using Robot FrameworkAsheesh Mehdiratta
 
Acceptance testing plone sites and add ons with robot framework and selenium
Acceptance testing plone sites and add ons with robot framework and seleniumAcceptance testing plone sites and add ons with robot framework and selenium
Acceptance testing plone sites and add ons with robot framework and seleniumAsko Soukka
 
Robot Framework Introduction & Sauce Labs Integration
Robot Framework Introduction & Sauce Labs IntegrationRobot Framework Introduction & Sauce Labs Integration
Robot Framework Introduction & Sauce Labs IntegrationSauce Labs
 
Robot Framework Introduction
Robot Framework IntroductionRobot Framework Introduction
Robot Framework IntroductionPekka Klärck
 
單元測試介紹
單元測試介紹單元測試介紹
單元測試介紹Adison wu
 
Nagios Conference 2012 - Sam Lansing - Automating Windows Application Testing...
Nagios Conference 2012 - Sam Lansing - Automating Windows Application Testing...Nagios Conference 2012 - Sam Lansing - Automating Windows Application Testing...
Nagios Conference 2012 - Sam Lansing - Automating Windows Application Testing...Nagios
 
Automation Testing with Sikuli
Automation Testing with SikuliAutomation Testing with Sikuli
Automation Testing with Sikulilionpeal
 
Test coverage in a jiffy v0 9
Test coverage in a jiffy v0 9Test coverage in a jiffy v0 9
Test coverage in a jiffy v0 9Indium Software
 
Designing Top-Class Test Suites for Web Applications
Designing Top-Class Test Suites for Web ApplicationsDesigning Top-Class Test Suites for Web Applications
Designing Top-Class Test Suites for Web ApplicationsLukáš Fryč
 
Toronto alm v1
Toronto alm v1Toronto alm v1
Toronto alm v1PowerStory
 
Software Automation Testing Introduction
Software Automation Testing IntroductionSoftware Automation Testing Introduction
Software Automation Testing IntroductionNarayanan Palani
 
Pytest testmon - executing large test suites quickly
Pytest testmon - executing large test suites quicklyPytest testmon - executing large test suites quickly
Pytest testmon - executing large test suites quicklytib0r
 
Robot Framework : Lord of the Rings By Asheesh M
Robot Framework : Lord of the Rings By Asheesh MRobot Framework : Lord of the Rings By Asheesh M
Robot Framework : Lord of the Rings By Asheesh MAgile Testing Alliance
 

En vedette (20)

JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan PeshovJavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
 
Acceptance Test Driven Development using Robot Framework
Acceptance Test Driven Development using Robot FrameworkAcceptance Test Driven Development using Robot Framework
Acceptance Test Driven Development using Robot Framework
 
Acceptance testing plone sites and add ons with robot framework and selenium
Acceptance testing plone sites and add ons with robot framework and seleniumAcceptance testing plone sites and add ons with robot framework and selenium
Acceptance testing plone sites and add ons with robot framework and selenium
 
Introduction to Robot Framework
Introduction to Robot FrameworkIntroduction to Robot Framework
Introduction to Robot Framework
 
Robot framework and selenium2 library
Robot framework and selenium2 libraryRobot framework and selenium2 library
Robot framework and selenium2 library
 
Robot Framework Introduction & Sauce Labs Integration
Robot Framework Introduction & Sauce Labs IntegrationRobot Framework Introduction & Sauce Labs Integration
Robot Framework Introduction & Sauce Labs Integration
 
Robot Framework Introduction
Robot Framework IntroductionRobot Framework Introduction
Robot Framework Introduction
 
單元測試介紹
單元測試介紹單元測試介紹
單元測試介紹
 
Nagios Conference 2012 - Sam Lansing - Automating Windows Application Testing...
Nagios Conference 2012 - Sam Lansing - Automating Windows Application Testing...Nagios Conference 2012 - Sam Lansing - Automating Windows Application Testing...
Nagios Conference 2012 - Sam Lansing - Automating Windows Application Testing...
 
Lets Auto It
Lets Auto ItLets Auto It
Lets Auto It
 
Selenium (2)
Selenium (2)Selenium (2)
Selenium (2)
 
Robot handles
Robot handlesRobot handles
Robot handles
 
Automation Testing with Sikuli
Automation Testing with SikuliAutomation Testing with Sikuli
Automation Testing with Sikuli
 
Sikuli
SikuliSikuli
Sikuli
 
Test coverage in a jiffy v0 9
Test coverage in a jiffy v0 9Test coverage in a jiffy v0 9
Test coverage in a jiffy v0 9
 
Designing Top-Class Test Suites for Web Applications
Designing Top-Class Test Suites for Web ApplicationsDesigning Top-Class Test Suites for Web Applications
Designing Top-Class Test Suites for Web Applications
 
Toronto alm v1
Toronto alm v1Toronto alm v1
Toronto alm v1
 
Software Automation Testing Introduction
Software Automation Testing IntroductionSoftware Automation Testing Introduction
Software Automation Testing Introduction
 
Pytest testmon - executing large test suites quickly
Pytest testmon - executing large test suites quicklyPytest testmon - executing large test suites quickly
Pytest testmon - executing large test suites quickly
 
Robot Framework : Lord of the Rings By Asheesh M
Robot Framework : Lord of the Rings By Asheesh MRobot Framework : Lord of the Rings By Asheesh M
Robot Framework : Lord of the Rings By Asheesh M
 

Similaire à Web testing automation

如何在實務上使用TDD來開發 twmvc#12
如何在實務上使用TDD來開發 twmvc#12如何在實務上使用TDD來開發 twmvc#12
如何在實務上使用TDD來開發 twmvc#12twMVC
 
twMVC#12 | 如何在實務上使用 TDD 來開發
twMVC#12 | 如何在實務上使用 TDD 來開發twMVC#12 | 如何在實務上使用 TDD 來開發
twMVC#12 | 如何在實務上使用 TDD 來開發twMVC
 
Top100summit automan x之框架介绍 王超
Top100summit automan x之框架介绍 王超Top100summit automan x之框架介绍 王超
Top100summit automan x之框架介绍 王超drewz lin
 
打造面向服务的敏捷团队 Q con-beijing2012
打造面向服务的敏捷团队 Q con-beijing2012打造面向服务的敏捷团队 Q con-beijing2012
打造面向服务的敏捷团队 Q con-beijing2012Qiao Liang
 
service-oriented agile team-Q con-beijing2012
service-oriented agile team-Q con-beijing2012service-oriented agile team-Q con-beijing2012
service-oriented agile team-Q con-beijing2012Qiao Liang
 
Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天
Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天
Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天Gelis Wu
 
Real World ASP.NET MVC
Real World ASP.NET MVCReal World ASP.NET MVC
Real World ASP.NET MVCjeffz
 
Top100summit 陈辉-游戏测试平台 策划资源文件自动化测试体系
Top100summit 陈辉-游戏测试平台 策划资源文件自动化测试体系Top100summit 陈辉-游戏测试平台 策划资源文件自动化测试体系
Top100summit 陈辉-游戏测试平台 策划资源文件自动化测试体系drewz lin
 
同济优秀课程设计 - 软件测试报告
同济优秀课程设计 - 软件测试报告同济优秀课程设计 - 软件测试报告
同济优秀课程设计 - 软件测试报告Kerry Zhu
 
Software Engineer Talk
Software Engineer TalkSoftware Engineer Talk
Software Engineer TalkLarry Cai
 
钱宝坤:多浏览器集成的JavaScript单元测试工具
钱宝坤:多浏览器集成的JavaScript单元测试工具钱宝坤:多浏览器集成的JavaScript单元测试工具
钱宝坤:多浏览器集成的JavaScript单元测试工具taobao.com
 
Static Code Analysis 靜態程式碼分析
Static Code Analysis 靜態程式碼分析Static Code Analysis 靜態程式碼分析
Static Code Analysis 靜態程式碼分析Bill Lin
 
Nhibernate+sqlite測試實戰經驗分享
Nhibernate+sqlite測試實戰經驗分享Nhibernate+sqlite測試實戰經驗分享
Nhibernate+sqlite測試實戰經驗分享Wade Huang
 
zhuwenlongChinese
zhuwenlongChinesezhuwenlongChinese
zhuwenlongChineseWenlong Zhu
 
Java 1(Java概述)
Java 1(Java概述)Java 1(Java概述)
Java 1(Java概述)xzdbd
 
ASP.Net MVC2 简介
ASP.Net MVC2 简介ASP.Net MVC2 简介
ASP.Net MVC2 简介Allen Lsy
 
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)twMVC
 
ASP.NET MVC 4 新功能介紹(快速上手) -twMVC#4
ASP.NET MVC 4 新功能介紹(快速上手) -twMVC#4ASP.NET MVC 4 新功能介紹(快速上手) -twMVC#4
ASP.NET MVC 4 新功能介紹(快速上手) -twMVC#4twMVC
 
软件工程 第十一章
软件工程 第十一章软件工程 第十一章
软件工程 第十一章浒 刘
 

Similaire à Web testing automation (20)

如何在實務上使用TDD來開發 twmvc#12
如何在實務上使用TDD來開發 twmvc#12如何在實務上使用TDD來開發 twmvc#12
如何在實務上使用TDD來開發 twmvc#12
 
twMVC#12 | 如何在實務上使用 TDD 來開發
twMVC#12 | 如何在實務上使用 TDD 來開發twMVC#12 | 如何在實務上使用 TDD 來開發
twMVC#12 | 如何在實務上使用 TDD 來開發
 
Top100summit automan x之框架介绍 王超
Top100summit automan x之框架介绍 王超Top100summit automan x之框架介绍 王超
Top100summit automan x之框架介绍 王超
 
打造面向服务的敏捷团队 Q con-beijing2012
打造面向服务的敏捷团队 Q con-beijing2012打造面向服务的敏捷团队 Q con-beijing2012
打造面向服务的敏捷团队 Q con-beijing2012
 
service-oriented agile team-Q con-beijing2012
service-oriented agile team-Q con-beijing2012service-oriented agile team-Q con-beijing2012
service-oriented agile team-Q con-beijing2012
 
PHP 单元测试
PHP 单元测试PHP 单元测试
PHP 单元测试
 
Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天
Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天
Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天
 
Real World ASP.NET MVC
Real World ASP.NET MVCReal World ASP.NET MVC
Real World ASP.NET MVC
 
Top100summit 陈辉-游戏测试平台 策划资源文件自动化测试体系
Top100summit 陈辉-游戏测试平台 策划资源文件自动化测试体系Top100summit 陈辉-游戏测试平台 策划资源文件自动化测试体系
Top100summit 陈辉-游戏测试平台 策划资源文件自动化测试体系
 
同济优秀课程设计 - 软件测试报告
同济优秀课程设计 - 软件测试报告同济优秀课程设计 - 软件测试报告
同济优秀课程设计 - 软件测试报告
 
Software Engineer Talk
Software Engineer TalkSoftware Engineer Talk
Software Engineer Talk
 
钱宝坤:多浏览器集成的JavaScript单元测试工具
钱宝坤:多浏览器集成的JavaScript单元测试工具钱宝坤:多浏览器集成的JavaScript单元测试工具
钱宝坤:多浏览器集成的JavaScript单元测试工具
 
Static Code Analysis 靜態程式碼分析
Static Code Analysis 靜態程式碼分析Static Code Analysis 靜態程式碼分析
Static Code Analysis 靜態程式碼分析
 
Nhibernate+sqlite測試實戰經驗分享
Nhibernate+sqlite測試實戰經驗分享Nhibernate+sqlite測試實戰經驗分享
Nhibernate+sqlite測試實戰經驗分享
 
zhuwenlongChinese
zhuwenlongChinesezhuwenlongChinese
zhuwenlongChinese
 
Java 1(Java概述)
Java 1(Java概述)Java 1(Java概述)
Java 1(Java概述)
 
ASP.Net MVC2 简介
ASP.Net MVC2 简介ASP.Net MVC2 简介
ASP.Net MVC2 简介
 
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
 
ASP.NET MVC 4 新功能介紹(快速上手) -twMVC#4
ASP.NET MVC 4 新功能介紹(快速上手) -twMVC#4ASP.NET MVC 4 新功能介紹(快速上手) -twMVC#4
ASP.NET MVC 4 新功能介紹(快速上手) -twMVC#4
 
软件工程 第十一章
软件工程 第十一章软件工程 第十一章
软件工程 第十一章
 

Web testing automation