10
WHITEPAPER AUGUST 2015 www.hcltech.com Automation Testing Pillar: Selenium AuthOr: Naveen Saxena Working 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. Q Ex Whitepaper Business Assurance & Testing

- HCL Technologies · 2015-08-14 · WHITEPAPER AugusT 2015 Automation Testing Pillar: selenium AuthOr: Naveen Saxena Working as a Test Lead, Center of Excellence Group, with HCL

Embed Size (px)

Citation preview

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 don’t 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 to run the selenium server for running the scripts. Selenium server is required when have to perform parallel execution through selenium grid or have to connect the remote machine.

AUTOMATION TESTING PILLAR: SELENIUM | AUGUST 2015

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

WebDriver API [2] makes the direct call to launch the browser using browser’s native call. For every browser, browser’s driver is present. Below is list for the same for Java.

y Internet Explorer: WebDriver driver = new InternetExplorerDriver();

y HtmlUnitDriver driver =new HtmlUnitDriver();

y Firefox: WebDriver driver = new FirefoxDriver();

y Chrome: WebDriver driver = new ChromeDriver();

y Opera: WebDriver driver = new OperaDriver();

Automation FrameworkSelenium Grid

Reports

Fig 7: Selenium 2.0

Selenium WebDriver API also supports the Android and IOS operating system. It has separate API to interact with it.

REPORTINGReporting is very important aspect for testing, In Selenium, there is predefined framework like Junit, TestNG which generates the HTML reports and there are so many API throughvomized report is generate. Selenium can integrate with test management tool like QC and Test link so report can be imported from these tools also.

Jenkins can also be used for report generation if we are following the CI practice.

AUTOMATION FRAMEWORK Automation framework [4] is strategy for the automation, it provides the structured way for the automation for obtaining the quality work with quantity and effectiveness.There are many predefined framework in Selenium like Junit, TestNG, Nunit etc. however implementation of hybrid framework concept with any predefined framework make selenium more effective.

Keyword driven approach for selenium web driver is more effective because there are maximum 30 to 40 keywords which can be converted into the reusable function and can be used for testing any web based application.

AUTOMATION TESTING PILLAR: SELENIUM | AUGUST 2015

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

CHALLENGES AND WORKAROUND y Client Server Interaction: While automation, there are scenarious like file uploading,

downloading, window Popup where selenium is helpess so AutoIT can be used to move further.

y Dynamic ID: There are some applications where web elements ID get changed everytime so it’s hard to use ID and xpath containing that ID so create the Xpath without id.

y Flash and Silver Light App: Selenium does not support however have to depend upon third party API however.

y BitMap: Image Comparison cannot be done in Selenium, can use Silkuli as third party tool.

CONCLUSION y Selenium in better option for the automation of the web based application.

y Increase the scope of testing.

y Provide more confidence to the customer.

y Regression and Smoke testing time will be condensed.

REFERENCES1. www.seleniumhq.org

2. www.gartner.com/www.jobsindeed.com

3. www.wiki.jenkins-ci.org/

4. www.guru99.com/www.onestoptesting.com

Hello there! I am an Ideapreneur. I believe that sustainable business outcomes are driven by relationships nurtured through values like trust, transparency and flexibility. I respect the contract, but believe in going beyond through collaboration, applied innovation and new generation partnership models that put your interest above everything else. Right now 105, 000 Ideapreneurs are in a Relationship Beyond the Contract™ with 500 customers in 31 countries. How can I help you?

ABOUT HCL

About HCL Technologies

HCL Technologies is a leading global IT services company working with clients in the areas that impact and redefine the core of their businesses. Since its emergence on the global landscape, and after its IPO in 1999, HCL has focused on ‘transformational outsourcing’, underlined by innovation and value creation, offering an integrated portfolio of services including software-led IT solutions, remote infrastructure management, engineering and R&D services and business services. HCL leverages its extensive global offshore infrastructure and network of offices in 31 countries to provide holistic, multi-service delivery in key industry verticals including Financial Services, Manufacturing, Consumer Services, Public Services and Healthcare & Life sciences. HCL takes pride in its philosophy of ‘Employees First, Customers Second’ which empowers its 104, 184 transformers to create real value for customers. HCL Technologies, along with its subsidiaries, had consolidated revenues of US$ 5.8 billion, for the Financial Year ended as on 31st March 2015 (on LTM basis). For more information, please visit www.hcltech.com

About HCL Enterprise

HCL is a $6.8 billion leading global technology and IT enterprise comprising two companies listed in India – HCL Technologies and HCL Infosystems. Founded in 1976, HCL is one of India’s original IT garage start-ups. A pioneer of modern computing, HCL is a global transformational enterprise today. Its range of offerings includes product engineering, custom & package applications, BPO, IT infrastructure services, IT hardware, systems integration, and distribution of information and communications technology (ICT) products across a wide range of focused industry verticals. The HCL team consists of over 109, 643 professionals of diverse nationalities, who operate from 31 countries including over 505 points of presence in India. HCL has partnerships with several leading global 1000 firms, including leading IT and technology firms. For more information, please visit www.hcl.com