- HCL Technologies .2015-08-14 · WHITEPAPER AugusT 2015 Automation Testing Pillar: selenium AuthOr:

  • View
    212

  • Download
    0

Embed Size (px)

Text of - HCL Technologies .2015-08-14 · WHITEPAPER AugusT 2015 Automation Testing Pillar: selenium...

  • WHITEPAPER AugusT 2015

    www.hcltech.com

    Automation Testing Pillar: selenium

    AuthOr: Naveen SaxenaWorking as a Test Lead, Center of Excellence Group, with HCL Technologies. Has immense expertise on Selenium, QTP and Load runner in Banking, Retail, Hospitality and Mobile Banking domain.

    QEx Whitepaper

    BusinessAssurance & Testing

  • AUTOMATION TESTING PILLAR: SELENIUM | AUGUST 2015

    2015, HCL TECHNOLOgIEs. REPRODuCTION PROHIBITED. THIs DOCuMENT Is PROTECTED uNDER COPYRIgHT BY THE AuTHOR, ALL RIgHTs REsERVED. 2

    TABLE OF CONTENTS

    1. INTRODUCTION 3

    2. WHY SELENIUM 4

    3. SELENIUM IMPLEMENTATION 6

    4. REPORTING 8

    5. AUTOMATION FRAMEWORK 8

    6. CHALLENGES AND WORKAROUND 9

    7. CONCLUSION 9

    8. REFERENCES 9

    9. AUTHOR 9

  • AUTOMATION TESTING PILLAR: SELENIUM | AUGUST 2015

    2015, HCL TECHNOLOgIEs. REPRODuCTION PROHIBITED. THIs DOCuMENT Is PROTECTED uNDER COPYRIgHT BY THE AuTHOR, ALL RIgHTs REsERVED. 3

    Abstract: Testing has become more decisive segment in SDLC. It is process which

    consists of the static and dynamic activities of the software life cycle. These activities

    cover the planning, analysis, design, execution and reporting and help to meet the certain

    goals for the evaluation software product. In the uprising world of the Internet, Automation

    testing is important aspect, it provides better 2Q (quality & quantity) work in small span of

    time .To achieve Automation, Commercial tools are there which are costly and small scale

    companies are not able to bear it so Selenium(Suite of tools) as an open source web

    based is rising solution. It is antinode for the commercial tool so the motive of the paper is

    to make organization aware of the Selenium, why Selenium, how it works, Integration with

    different API and workaround for Selenium Challenge

    INTRODUCTIONSelenium [1] is an open source functional automation tool for the web based application. It was developed by the Thought Work in 2004. It is remarkable tool for the functional software testing

    Fig 1: Selenium Demand [2]

    There are two versions for the Selenium:

    y Selenium 1.0: It consists of below tool suite: Selenium IDE

    Selenium RC Client/ Server

    Selenium Grid

    y Selenium 2.0: It consists of below tool suite: Selenium IDE

    Selenium Server

    Selenium Grid

  • AUTOMATION TESTING PILLAR: SELENIUM | AUGUST 2015

    2015, HCL TECHNOLOgIEs. REPRODuCTION PROHIBITED. THIs DOCuMENT Is PROTECTED uNDER COPYRIgHT BY THE AuTHOR, ALL RIgHTs REsERVED. 4

    WHY SELENIUM

    Fig 2: Selenium Tree

    It is rich from the Selenium Tree, Below are the points:

    y Cost effective: It is an open source tool.

    y Language: Supports many languages like Java, Ruby, and Python and C #.

    y Browser: Supports multiple browsers like IE, Mozilla, Opera, Chrome and Safari so can be used for cross browser testing and can be integrated easily to new launched browser.

    y Framework: Supports multiple frame -works like Junit, TestNG, Bromine, Nunit, Rspec which make the automation more robust and can developed own framework.

    y Operating System: Supports multiple operating systems like Windows, IOS, Linux and Android.

    y Time Saving: With the help of selenium grid, Parallel execution of the test cases can be done.

    Selenium Integration /As Tool Suite

  • AUTOMATION TESTING PILLAR: SELENIUM | AUGUST 2015

    2015, HCL TECHNOLOgIEs. REPRODuCTION PROHIBITED. THIs DOCuMENT Is PROTECTED uNDER COPYRIgHT BY THE AuTHOR, ALL RIgHTs REsERVED. 5

    Selenium supports multiple client as Java, .Net etc.. This makes it more robust to integrate with others to resolve challenges as well as more solution on different -2 platforms.

    y Auto IT: Automate the client sever test scenario, able to handle the window pop up.

    y Appium: Mobile Automation on Android and IOS.

    y Sikuli: Able to recognize the image and able to handle the window pop up .

    y Selendriod: Mobile Automation on Android and IOS.

    y Cucumber/Jbehave: Able to start automation from first day

    Selenium Integration with Jenkins[3] (Continuous Integration)

    This is one of the pillar features which make force to organisation to go for Selenium. Below are points for the same.

    y Automation scripts can be triggered automatically after every build and all results can be pushed to dashboard all stakes holders.

    y Automation scripts up gradation can be integrated continuously without any delay with existing scripts.

    y Fit into the agile methlodgy and provide assurance for quality product.

    y Execution can be schedule as per the requirement.

    Selenium able to automate the Dynamic Object

    One of the key challenge for web automation to automate the web objects whose properties are keep getting changed for each session, X-path support mechanism to identity /solve this issue in following ways:

    y Create X-path without containing the locator like ID, Class, Tag name etc. For Example: //*[@id=txtUserID] = = //div/table/tbody/tr[2]/td[2]/p/input

    y Create the X-path with function Start With when the partial id is constant. For Example: //*[@id=txtUserID] = = //* [starts-with (@id, txtUs)]

    y Create the X-path with function Contains. For Example: //*[@id=txtUserID] = = //* [contains(@id, UserID)]

    HtmlUnitWeb Driver: Selenium Headless Browser Automation Testing:

    Headless browser is a simulation of browser which dont have any GUI .HtmlUnitDriver provides the headless browser automation in selenium. There will be no execution displayed like real browser and there are following other benefits:

    y Execution is quicker.

    y Java script is supported in HtmlUnitWeb Driver.

  • AUTOMATION TESTING PILLAR: SELENIUM | AUGUST 2015

    2015, HCL TECHNOLOgIEs. REPRODuCTION PROHIBITED. THIs DOCuMENT Is PROTECTED uNDER COPYRIgHT BY THE AuTHOR, ALL RIgHTs REsERVED. 6

    y Execution can taken place without browser.

    y Multiple browser versions are supported by Html Unit Web Driver.

    Selenium Integration with Quality Centre (Test Management Tool)

    Selenium Script can be integrated with Quality centre as well. Vapi script can be written in side QC and execution can be triggered from QC directly

    Integration with BDD tool

    BDD Tool facilitates automation without GUI so the automation testing can be started in early cycle of testing when the product is under development. Once the GUI developed, the BDD scripts can be incorporated with Selenium with minimal effort and GUI automation will be accomplished in less time.

    SELENIUM IMPLEMENTATIONSelenium has two versions, Selenium 1.0 and Selenium 2.0. Both the versions have common components.

    Selenium IDE

    Selenium Grid

    Selenium Server

    Selenium RC/

    Client Server

    Selenium 1.0. Selenium 2.0.Webdriver

    Fig 4: Selenium Venn diagram

    Selenium IDE: Selenium IDE [1] is plugin to Firefox so can be downloaded easily .Selenium ide is used for record and play back functionality, the default script is generated in html and can play back in html format only on Firefox. For starting the Selenium IDE navigate tools option present in menu bar of the Firefox and click on Selenium IDE option. By default, Selenium IDE is in recording mode and start navigating the application on Firefox browser and perform the action, all the actions are recorded and can be seen parallel into Selenium IDE.

    There are two tabs present on it, Table & Source .Under Source Tab HTML format or code of the recording can be analysed and under Table tab, there are three columns:

    y Command: It shows the action going to perform like Click, enter etc.

    y Target: It is or objects property where the action is going to perform.

    y Value: Any input value is shown here.

  • AUTOMATION TESTING PILLAR: SELENIUM | AUGUST 2015

    2015, HCL TECHNOLOgIEs. REPRODuCTION PROHIBITED. THIs DOCuMENT Is PROTECTED uNDER COPYRIgHT BY THE AuTHOR, ALL RIgHTs REsERVED. 7

    After completing the recording, Test case can be exported into different language by navigating option File>>Export Test case AS, In similar way, multiple test cases can be recorded and exported as the Test suite.

    Fig 5: Selenium IDE

    After completing the recording, Test case can be exported into different language by navigating option File>>Export Test case AS, In similar way, multiple test cases can be recorded and exported as the Test suite.

    The HTML code can also be converted directly to the different different language without exporting the test case, click the option Options>>Format and select the language in which want to convert the test case.

    In previous version of selenium-ide, conditional statements like while/for and parameterization cannot be done now it can be done by adding selenium ide extension however it is not that much robust so make the Selenium more effective, Selenium RC/Client is used.

    Selenium Grid: Selenium Grid [1] is most important aspect of the selenium. With the help of this, parallel execution can be done on different different platform with different browser. It saves the time and increases the coverage of the testing on the platform basis and provides the quality software product.

    Selenium 2.0: Selenium 2.0 [1] is the updated version of Selenium 1.0, it is also known as the Selenium WebDriver. It is completely based on the object oriented API so supposed to be more robust and can support in better way for the web based testing., Selenium IDE & Selenium Grid are working in similar way as implemented in selenium 1.0 however there is no need