SlideShare a Scribd company logo
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

More Related Content

PPTX
Sonar Qube tool introduction
PDF
Agile Taichung sharing Robot Framework 2018/05/19
PDF
測試是什麼
PPS
测试快照
PPT
quick_orm 简介
PDF
PDF
使用 Pytest 進行單元測試 (PyCon TW 2021)
PDF
Testing in Python @ Kaosiung.py 2014.05.26
Sonar Qube tool introduction
Agile Taichung sharing Robot Framework 2018/05/19
測試是什麼
测试快照
quick_orm 简介
使用 Pytest 進行單元測試 (PyCon TW 2021)
Testing in Python @ Kaosiung.py 2014.05.26

Viewers also liked (20)

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

Similar to Web testing automation (15)

PPTX
Automated Web Testing Using Selenium
PDF
BDD in .NET
ODP
PHPUnit
PDF
Katalon Demo v11.pdf
PPT
Selenium介绍
PDF
Top100summit automan x之框架介绍 王超
PDF
Continuous integration
PDF
Python系列1
ODP
PHPUnit slide formal
PDF
單元測試:Mocha、Chai 和 Sinon
PDF
Continuous Delivery: automated testing, continuous integration and continuous...
PDF
Asp net
PDF
Foundation of software development 1
PDF
用 DevOps 思維看待網頁測試
PDF
Foundation of software development 2
Automated Web Testing Using Selenium
BDD in .NET
PHPUnit
Katalon Demo v11.pdf
Selenium介绍
Top100summit automan x之框架介绍 王超
Continuous integration
Python系列1
PHPUnit slide formal
單元測試:Mocha、Chai 和 Sinon
Continuous Delivery: automated testing, continuous integration and continuous...
Asp net
Foundation of software development 1
用 DevOps 思維看待網頁測試
Foundation of software development 2
Ad

Recently uploaded (20)

PPTX
3分钟读懂曼彻斯特城市大学毕业证MMU毕业证学历认证
PPTX
3分钟读懂索尔福德大学毕业证Salford毕业证学历认证
PPTX
A Digital Transformation Methodology.pptx
PPTX
3分钟读懂贵湖大学毕业证U of G毕业证学历认证
PPTX
模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板
PPTX
3分钟读懂伦敦政治经济学院毕业证LSE毕业证学历认证
PPTX
ONU and OLT from Baudcom Jenny training PPT
PPTX
《HSK标准教程4下》第15课课件new.pptx HSK chapter 15 pptx
PPTX
3分钟读懂伦敦大学学院毕业证UCL毕业证学历认证
PPTX
3分钟读懂利物浦约翰摩尔大学毕业证LJMU毕业证学历认证
PPTX
3分钟读懂滑铁卢大学毕业证Waterloo毕业证学历认证
PPTX
3分钟读懂纽曼大学毕业证Newman毕业证学历认证
PPTX
3分钟读懂加州大学欧文分校毕业证UCI毕业证学历认证
PPTX
3分钟读懂肯塔基大学毕业证UK毕业证学历认证
PPTX
3分钟读懂皇家艺术学院毕业证RCA毕业证学历认证
PPTX
3分钟读懂拉夫堡大学毕业证LU毕业证学历认证
PPTX
3分钟读懂诺里奇艺术大学毕业证NUA毕业证学历认证
PPTX
3分钟读懂圭尔夫大学毕业证U of G毕业证学历认证
PPTX
3分钟读懂南威尔士大学毕业证UCB毕业证学历认证
PDF
黑客技术,安全提分不是梦!我们采用最新的数据破解和隐藏技术,精准定位并修改你的成绩,同时采用深度隐藏技术确保你的操作不被发现。价格实惠,流程快速,事后无痕...
3分钟读懂曼彻斯特城市大学毕业证MMU毕业证学历认证
3分钟读懂索尔福德大学毕业证Salford毕业证学历认证
A Digital Transformation Methodology.pptx
3分钟读懂贵湖大学毕业证U of G毕业证学历认证
模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板模板
3分钟读懂伦敦政治经济学院毕业证LSE毕业证学历认证
ONU and OLT from Baudcom Jenny training PPT
《HSK标准教程4下》第15课课件new.pptx HSK chapter 15 pptx
3分钟读懂伦敦大学学院毕业证UCL毕业证学历认证
3分钟读懂利物浦约翰摩尔大学毕业证LJMU毕业证学历认证
3分钟读懂滑铁卢大学毕业证Waterloo毕业证学历认证
3分钟读懂纽曼大学毕业证Newman毕业证学历认证
3分钟读懂加州大学欧文分校毕业证UCI毕业证学历认证
3分钟读懂肯塔基大学毕业证UK毕业证学历认证
3分钟读懂皇家艺术学院毕业证RCA毕业证学历认证
3分钟读懂拉夫堡大学毕业证LU毕业证学历认证
3分钟读懂诺里奇艺术大学毕业证NUA毕业证学历认证
3分钟读懂圭尔夫大学毕业证U of G毕业证学历认证
3分钟读懂南威尔士大学毕业证UCB毕业证学历认证
黑客技术,安全提分不是梦!我们采用最新的数据破解和隐藏技术,精准定位并修改你的成绩,同时采用深度隐藏技术确保你的操作不被发现。价格实惠,流程快速,事后无痕...

Web testing automation