<<

IJSRD - International Journal for Scientific Research & Development| Vol. 6, Issue 03, 2018 | ISSN (online): 2321-0613

Automation Testing using Web Driver & Behavior Driven Development (BDD) Srashti Lariya1 Dr. Sameer Shrivastava2 Er. Sumit Nema3 1M.Tech. Scholar 2,3Assistant Professor 1,2,3Department of Computer Science & Engineering 1,2,3Global Nature Care Sanghtan’s Group of Institution, Jabalpur, India Abstract— Testing is the most relevant phase in SDLC. Selenium Web Driver and Selenium Grid. Here we are using Testing is the quality assurance stage and done to point out Selenium Web Driver. the errors and bugs came during development so that it gives Selenium Web Driver is also known as Selenium 2.0 satisfaction and reliability to the customer over application. [5]. it is a tool used to test web application. It can directly Tester envisions business situation by their Critical thinking communicate with browser which make it faster than and rational approach. To ease the work of a tester the SeleniumRC whereas SeleniumRC uses Selenium RC server automated tools can execute, report and compare the result which inject a http proxy in browser to understand your with previous test runs. In this paper, our objective is to browsers. To automate test suite in selenium web driver test generate detailed output report having information about test cases are created and then they are executed by element cases executed in the test run. We are using BDD framework locator, object locater and web driver methods. Web Driver for testing a web application with the help of open source does not have confusing commands it supports data driven selenium web driver, Maven and . We will create a testing. Test scripts in any language invokes selenium web feature file for each requirement and map it to corresponding driver and automate its web application making it faster and step definition class. As we run the feature file it will execute easy to understand. Selenium web driver cannot generate all the mapped methods in step definition class. The output detailed test reports, so we use BDD (feature file) which will generated will have detailed information about the cases make detailed test reports. executed as written in feature file. Key words: Behavioral Driven Development (BDD), II. UNDERSTANDING CONCEPT OF BDD FRAMEWORK Selenium Web Driver, Cucumber, Maven and Test NG Behavioral driven development methodology is used for software development where all the member of team I. INTRODUCTION communicates to understand the entire requirement. Here In software Development process clients will describe all its product owner, tester, business analyst and developer talk need to Business Analyst, business analyst then validates the about business needs and collaborate around the requirement. gathered requirements and design the software as per client’s [11] The owner specifies its need and behavior they want to essential needs. In the third phase it goes to a developer, they see in software. These interactions help developer and tester carefully understand the given requirements by the business to deliver the well-defined result. With the help of user analyst and come up with the code. Quality Assurance team stories, they get clear understanding and write the will design the scenarios to test the software. requirements into feature file which is in plain English Software Testing is done in a systematic manner to language known as gherkin. Some advantages of BDD find bugs which also ensure that our actual result and 1) Strong collaboration expected result should be same [8]. To increase the success 2) High visibility rate we do automation testing over manual testing. We have 3) The software design follows business value two basic techniques for testing. One is Black box testing, and 4) ubiquitous language another is known as White box testing. [3] In Black box 5) More confidence from the developers' side testing internal testing process is ignored, and it mainly 6) Lower costs focuses in the functionality of any application, it is usually A. Cucumber done in a validation process. Validation is done, so we can check the specified customer requirement is satisfied or not. Cucumber is software testing tool, it builds understanding In another testing i.e. White box testing, internal process flow between the business manager and software developer, of an application and developed code is tested. Here cucumber is created to process Behavioral driven automation testing is done by using selenium, which is used development (BDD) in which requirements are implicated in for regression and functional testing. Regression and a feature files which is in plain English called as Gherkin functional testing comes under black box testing. language. [12] It is in the format of “Given, When, Then”. Selenium is a set of API [2] and Jars which help us The test scenarios written in Gherkin language are placed in to automate web applications before deployment. Selenium a Feature File. Before starting the actual development, the supports different operating system to be a platform scrum team will understand the requirement, and then quality independent, different browsers and many programming assurance team will write step definition. languages. Selenium has multiple tools with different B. Feature File functionality and capability to operate. [2] These tools are When test cases are written in files then these file are known selenium IDE (Integrated Development Environment), as feature file. In cucumber, for every functionality we Selenium RC (Remote Control) which is deprecated, prepare different feature files. For specific feature file we create a scenario and scenario outline. File is in “.feature”

All rights reserved by www.ijsrd.com 2014 Automation Testing using Selenium Web Driver & Behavior Driven Development (BDD) (IJSRD/Vol. 6/Issue 03/2018/481) extension. Feature file consist of some simple keyword they Accordingly, developers and testers proceeds with the coding are and test case writing respectively. 1) Feature –It defines specific functionality in test case. 2) Scenario –It defines how the functionality work. VI. AIRLINE APPLICATION 3) Given – What is given to us. Airline application is formed to provide facilities like Search 4) When − Next Specific condition. a flight, book a flight, cancel a ticket, etc to the customers. 5) Then − What happen if condition satisfied. This Application will help user to explore various options to Scenario outline - we will give multiple inputs for a travel from. Customer can manage and view his recent tickets single scenario so that it can check multiple input as this application offers to create an account in which all the C. Step Definition past and future tickets would be listed. As the competition in To execute our job written in feature file, we call an the market has been increase in recent years, Customer is intermediate step definition class. All the steps of feature file looking for cheapest and reliable flight options. This are mapped with the code of function for execution. Now Application would provide best flights available according to cucumber execute all the scenario of feature file by scanning the customer searches. step definition file We will test the following functionalities in Airline 1) Annotation Application: There is some pre-defined text in cucumber which will help 1) Login to account (Successful and Unsuccessful) the compiler for execution 2) Search a flight

VII. EXPERIMENTATION & IMPLEMENTATION III. MAVEN Maven is a software management tool. In maven we add A. Problem Analysis specific dependencies which are required in our project. In this section, we will discuss about problems faced in past Maven is used to build project. Maven work on project object to analyze the test result, Indeed they have used TestNG for model. POM is an xml file. POM file contains data about the better reporting and knowledge of the Business user. But still software project. POM configures our project. Maven problem is not fully resolved as TestNG report would not download java libraries and plugins form repository. Maven provide detailed information about the cases executed help us by downloading all the important jar required for the project. A. Dependency We will add certain specific dependency by giving their artifact id, group id, version and scope. Further it will download all its jar file from web server maven repository.

IV. TESTNG In our project we will use TestNG framework as it is more powerful. Here NG denotes next generation. It is open source working tool and better suited in integration testing A. Benefits of TestNG 1) Prioritizing of test case 2) Sequencing is done Fig. 1: TestNG report 3) Test cases are Grouped In figure 1, TestNG is providing information about 4) Parallel testing. passed scenarios and methods, indeed execution time is also 5) Generation of Logs being displayed, yet there are some flaws as it does not 6) Annotations provide detailed information about the scenarios which are 7) TestNG can give HTML reports. passed or failed and which step was failed in case of failure. B. Annotation Annotation can identify methods. There is no pattern or format for method. Additional parameters can be passed. Annotations help compiler to find errors easily.

V. REQUIREMENT SPECIFICATION Software Requirement Specification is a descriptive document for software requirements. It is shared by stake holders and business analyst developers and testers.

All rights reserved by www.ijsrd.com 2015 Automation Testing using Selenium Web Driver & Behavior Driven Development (BDD) (IJSRD/Vol. 6/Issue 03/2018/481)

Fig. 4: Feature File for Login Functionality 2) Search Page In figure 5, Search page is shown. User will enter the source and destination, date of travelling and number of persons. When user clicks search button then list of flights which Fig. 2: Maven Pom.Xml File fulfill the search criteria should be displayed In figure 2, the POM.xml file is shown. It contains certain dependencies. We can add all the dependencies that are required to test our application. Maven will fetch all the jar files from its repository. B. Writing Test Cases

1) Login Page Figure 5: Search Page In figure 3, There are three components in login page. They Figure 6 is displaying the feature file of search are email box (text box), password box (text box) and login functionality here we will write our scenario in a simple button (submit button) gherkin language with the help of “given, when, then” In email text box we will enter registered email ID keywords. of the customer. There are two cases for login: 1) Login with registered email. 2) Login with unregistered email. When user enter correct and registered Email ID and Password, customer should get logged into account. When user enter incorrect or unregistered email ID and password, customer should not be able to login to the account Fig. 6: Feature File for Search Functionality Figure 7 is showing the result of search page, here we can see all the available flight according to the selection.

Fig. 3: Login Page In Figure 4, Login Feature file is being displayed – we have created a feature file for login functionality of airline Fig. 7: Result of Search File application. Every line in feature file is mapped with its corresponding code in step definition class. We have used VIII. RESULT OF THE TEST Scenario Outline to run the test case with two different sets of data. Figure 8 is showing the output of our cucumber runner. This When I run a feature file as a cucumber feature, it figure is showing the output of login functionality. Where one will execute corresponding method in step definition class in scenario outline is passed and another get failed. a sequence (given, when, then). The same flow will execute for all set of data present in example of scenario outline in feature file.

All rights reserved by www.ijsrd.com 2016 Automation Testing using Selenium Web Driver & Behavior Driven Development (BDD) (IJSRD/Vol. 6/Issue 03/2018/481)

Selenium Testing tool with respect to Integration Testing," IJCST International Journal of Computer Science and technology, vol. 2, no. 3, pp. 165-170, September 2011. [6] V. K. Shah, "Dynamic Heuristic Approach of An Acceptance Test Data Generation with Behavior Driven For Selenium Test," International Journal of Scientific & Engineering Research, vol. 3, no. 6, June 2012. [7] L. Nagowah and K. Doorgah, "Improving Test Data Management in Record and," IEEE, pp. 931-937, 2012. [8] Jagannatha, Niranjanamurthy, Manushree and Chaitra, "Comparative Study on Automation Testing using Selenium Testing Framework and QTP," International Journal of Computer Science and Mobile Computing, Fig. 8: Output for Cucumber vol. 3, no. 10, pp. 258-267, October 2014. Here we can clearly identify which test is passed and [9] S. Singla and H. Kaur, "Selenium Keyword Driven which test is getting failed. This output figures are showing Automation Testing Framework," International Journal how it would clearly overcome the drawback encountered in of Advanced Research in Computer Science and the TestNG. Software Engineering, vol. 4, no. 6, pp. 125-129, June Figure 9 is displaying the output of search 2014. functionality that indicates which scenarios and steps have [10] P. Bindal, " Selenium WebDriver using passed. TestNG," Journal of Engineering Computers & Applied Sciences(JECAS), vol. 3, no. 9, September 2014. [11] S. Gojarea, R. Joshib and D. Gaigaware, "Analysis and Design of Selenium WebDriver Automation Testing," science direct, pp. 341-346, 2015. [12] Chandraprabha, A. Kumar and S. Saxena, "Data Driven Testing Framework using Selenium," International Journal of Computer Applications, vol. 118, no. 18, pp. 18-23, May 2015. [13] R. J. C and R. Kaluri, "DESIGN OF AUTOMATION SCRIPTS EXECUTION APPLICATION FOR SELENIUM WEBDRIVER AND TestNG FRAMEWORK," ARPN Journal of Engineering and Applied Sciences, vol. 10, no. 6, pp. 2440-2445, 2015. Fig. 9: Output of Cucumber for Searching a Flight [14] P. A. Motwani, A. Agrawal, D. P. N. Singh and P. A. Shrivastava, "Novel Framework for Browser IX. CONCLUSION Compatibility Testing of a Web Application using In this paper we have used BDD Framework with selenium Selenium," (IJCSIT) International Journal of Computer web Driver. In accordance to improve collaboration and Science and Information Technologies, vol. 6, pp. 5196- understanding between involving parties. It also provides 5162, 2015. high visibility to all participants as it uses ubiquitous [15] okolnhchyi and k. fogen, "A study of tools for behavior language which would be understood by all. As a result of driven development," RWTH aachen university, this, Developers are able to provide high quality product Germany, 2016. which meets user need precisely and reduce the maintenance [16] keus and a. dyck, "How much does testing cost," in SWC cost for code. seminar RWTH achen university, Germany, 2016. [17] "Guru99," [Online]. Available: REFERENCES https://www.guru99.com/selenium-tutorial.html. [1] P. V. Sagar, R. Paruchuri and S. Vemuri, "Testing using [18] "Seleniumhq," [Online]. Available: selenium web driver," IEEE, 23 November 2017. https://www.seleniumhq.org/. [2] D. Gaur and D. R. S. Chhilla, "Implementation of Selenium with JUNIT and Test-Ng," IJCSMS International Journal of Computer Science and Management Studies, vol. 12, no. 3, pp. 226-232, 2012. [3] K. a. D. W. Andreas Bruns, "Web Application Tests," IEEE, pp. 88-91, 2009. [4] S. Sivanandan and Y. C. B, "Agile Development Cycle: Approach to Design an Effective Model Based Testing". [5] P. Yalla, D. L. S. S. Reddy, M.Srinivas and S. M. Rao, "Framework for Testing Web Applications using

All rights reserved by www.ijsrd.com 2017