Automation Testing Pillar: selenium QExWhitepaper

Transcription

Automation Testing Pillar: selenium QExWhitepaper
www.hcltech.com
QEx Whitepaper
Automation Testing
Pillar: Selenium
Business
Assurance
& Testing
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.
WHITEPAPER
August 2015
AUTOMATION TESTING PILLAR: SELENIUM
|
August 2015
TABLE OF CONTENTS
1. INTRODUCTION3
2. WHY SELENIUM
4
3. SELENIUM IMPLEMENTATION
6
4. REPORTING8
5. AUTOMATION FRAMEWORK 8
6. CHALLENGES AND WORKAROUND
9
7. CONCLUSION9
8. REFERENCES9
9. AUTHOR9
© 2015, HCL TECHNOLOGIES. REPRODUCTION PROHIBITED. THIS DOCUMENT IS PROTECTED UNDER COPYRIGHT BY THE AUTHOR, ALL RIGHTS RESERVED.
2
AUTOMATION TESTING PILLAR: SELENIUM
|
August 2015
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
INTRODUCTION
Selenium [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:
yy Selenium 1.0: It consists of below tool suite:
–– Selenium IDE
–– Selenium RC Client/ Server
–– Selenium Grid
yy Selenium 2.0: It consists of below tool suite:
–– Selenium IDE
–– Selenium Server
–– Selenium Grid
© 2015, HCL TECHNOLOGIES. REPRODUCTION PROHIBITED. THIS DOCUMENT IS PROTECTED UNDER COPYRIGHT BY THE AUTHOR, ALL RIGHTS RESERVED.
3
AUTOMATION TESTING PILLAR: SELENIUM
|
August 2015
WHY SELENIUM
Fig 2: Selenium Tree
It is rich from the Selenium Tree, Below are the points:
yy Cost effective: It is an open source tool.
yy Language: Supports many languages like Java, Ruby, and Python and C #.
yy 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.
yy Framework: Supports multiple frame -works like Junit, TestNG, Bromine, Nunit,
Rspec which make the automation more robust and can developed own framework.
yy Operating System: Supports multiple operating systems like Windows, IOS,
Linux and Android.
yy Time Saving: With the help of selenium grid, Parallel execution of the test cases
can be done.
Selenium Integration /As Tool Suite
© 2015, HCL TECHNOLOGIES. REPRODUCTION PROHIBITED. THIS DOCUMENT IS PROTECTED UNDER COPYRIGHT BY THE AUTHOR, ALL RIGHTS RESERVED.
4
AUTOMATION TESTING PILLAR: SELENIUM
|
August 2015
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.
yy Auto IT: Automate the client sever test scenario, able to handle the window
pop up.
yy Appium: Mobile Automation on Android and IOS.
yy Sikuli: Able to recognize the image and able to handle the window pop up .
yy Selendriod: Mobile Automation on Android and IOS.
yy 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.
yy Automation scripts can be triggered automatically after every build and all results
can be pushed to dashboard all stakes holders.
yy Automation scripts up gradation can be integrated continuously without any delay
with existing scripts.
yy Fit into the agile methlodgy and provide assurance for quality product.
yy 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:
yy 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
yy Create the X-path with function Start –With when the partial id is constant.
For Example: //*[@id=’txtUserID’] = = //* [starts-with (@id, ‘txtUs’)]
yy 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:
yy Execution is quicker.
yy Java script is supported in HtmlUnitWeb Driver.
© 2015, HCL TECHNOLOGIES. REPRODUCTION PROHIBITED. THIS DOCUMENT IS PROTECTED UNDER COPYRIGHT BY THE AUTHOR, ALL RIGHTS RESERVED.
5
AUTOMATION TESTING PILLAR: SELENIUM
|
August 2015
yy Execution can taken place without browser.
yy 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 IMPLEMENTATION
Selenium has two versions, Selenium 1.0 and Selenium 2.0. Both the versions have
common components.
Selenium
RC/
lient Server
C
Selenium
IDE
Selenium
Grid
Selenium 1.0.
Selenium
Server
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:
yy Command: It shows the action going to perform like Click, enter etc.
yy Target: It is or objects property where the action is going to perform.
yy Value: Any input value is shown here.
© 2015, HCL TECHNOLOGIES. REPRODUCTION PROHIBITED. THIS DOCUMENT IS PROTECTED UNDER COPYRIGHT BY THE AUTHOR, ALL RIGHTS RESERVED.
6
AUTOMATION TESTING PILLAR: SELENIUM
|
August 2015
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.
© 2015, HCL TECHNOLOGIES. REPRODUCTION PROHIBITED. THIS DOCUMENT IS PROTECTED UNDER COPYRIGHT BY THE AUTHOR, ALL RIGHTS RESERVED.
7
AUTOMATION TESTING PILLAR: SELENIUM
|
August 2015
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.
yy Internet Explorer: WebDriver driver = new InternetExplorerDriver();
yy HtmlUnitDriver driver =new HtmlUnitDriver();
yy Firefox: WebDriver driver = new FirefoxDriver();
yy Chrome: WebDriver driver = new ChromeDriver();
yy Opera: WebDriver driver = new OperaDriver();
Reports
Selenium Grid
Automation Framework
Fig 7: Selenium 2.0
Selenium WebDriver API also supports the Android and IOS operating system. It has
separate API to interact with it.
REPORTING
Reporting 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.
© 2015, HCL TECHNOLOGIES. REPRODUCTION PROHIBITED. THIS DOCUMENT IS PROTECTED UNDER COPYRIGHT BY THE AUTHOR, ALL RIGHTS RESERVED.
8
AUTOMATION TESTING PILLAR: SELENIUM
|
August 2015
CHALLENGES AND WORKAROUND
yy 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.
yy 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.
yy Flash and Silver Light App: Selenium does not support however have to depend
upon third party API however.
yy BitMap: Image Comparison cannot be done in Selenium, can use Silkuli as third
party tool.
CONCLUSION
yy Selenium in better option for the automation of the web based application.
yy Increase the scope of testing.
yy Provide more confidence to the customer.
yy Regression and Smoke testing time will be condensed.
REFERENCES
1. www.seleniumhq.org
2. www.gartner.com/www.jobsindeed.com
3. www.wiki.jenkins-ci.org/
4. www.guru99.com/www.onestoptesting.com
© 2015, HCL TECHNOLOGIES. REPRODUCTION PROHIBITED. THIS DOCUMENT IS PROTECTED UNDER COPYRIGHT BY THE AUTHOR, ALL RIGHTS RESERVED.
9
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
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?