International Journal of Advanced Research in Engineering and Technology (IJARET) Volume 9, Issue 4, July August 2018, pp. 180 186, Article ID: IJARET_09_04_020 Available online at http://www.iaeme.com/ijaret/issues.asp?jtype=ijaret&vtype=9&itype=4 ISSN Print: 0976-6480 and ISSN Online: 0976-6499 IAEME Publication KEYWORD DRIVEN TESTING FRAMEWORK USING SELENIUM WEBDRIVER Nisha Jha and Rishu Gulati Assistant Professor, School of Computer Science, Lingaya s Vidyapeeth, Faridabad ABSTRACT The growing numbers of web applications have continuous impact on our lives. Since the internet is itself heterogeneous and distributed, the growing number of web applications adds to its complex nature. Besides its dynamic computing environment, the needs of high quality applications add to the complexity in designing and the testing these applications. So the proper testing of web applications is needed to ensure reliability, robustness and high performance. Selenium Webdriver has evolved as one of the best testing tool for web applications. Keyword Driven Testing Framework uses Selenium Webdriver for performing web testing. It enhances the capabilities of Selenium Webdriver. It allows testing with minimum effort and time using the concept of Reusability. Keywords: Software Testing, Automation, Web Testing, Selenium WebDriver, Keyword Driven Testing Cite this Article: Nisha Jha and Rishu Gulati, Keyword Driven Testing Framework Using Selenium Webdriver, International Journal of Advanced Research in Engineering and Technology, 9(4), 2018, pp 180 186. http://www.iaeme.com/ijaret/issues.asp?jtype=ijaret&vtype=9&itype=4 1. INTRODUCTION The fast pace growth of internet has made testing of web applications more complicated. Testers have to face varied challenges while testing such complex web systems like supporting multiple browsers, cross platform support, handling load and wait conditions, lash objects, multi-language support and so on [1]. Selenium WebDriver ensures that the tester will be able to handle all such challenges or conditions. Selenium WebDriver work in two steps, initially find the location of the web element and then perform some action on them using methods. Selenium WebDriver aids the facility to locate web elements by using id, name, Xpath, CSSpath, link_text, partial_link_text and many more. Selenium WebDriver provides a large set of functions to test an online application [11]. A keyword-driven testing framework can be a table-driven testing or testing based on action words. It is a software testing technique appropriate for both manual and automatic testing. A keyword-driven testing could be a scripting technique that uses data files to incorporate the keywords associated with the utility being tested. These keywords define the set of actions that s needed to carry out a specific step. http://www.iaeme.com/ijaret/index.asp 180 editor@iaeme.com
Keyword Driven Testing Framework Using Selenium Webdriver The Keyword Driven Testing Framework has been developed to perform Automation Testing for web applications that use Selenium Webdriver as functional testing tool [15]. By the use of Keyword Driven Framework, rather than writing multiple functions to automate driven website, those things have been abstracted to excel documents. After which in that excel file, the steps are written and therefore the program code written, goes to drive best on the data excel set and the entire functionality of the Application under Test (AUT) gets captured as step by step instructions for every test as well as in a table. In this way, test cases are automatically tested with the aid of the usage Keyword driven testing framework [10]. This requires the development of data tables and keywords, independent of the test automation tool used to execute them and the test script code that drives the Application under Test (AUT) and the data. Keyword Driven Tests look very similar to manual test cases. In this, the functionality of AUT is documented in a table as well as in step by step instructions for each test [8]. In another words, in Keyword Driven Testing, initially identify a set of keywords and then associate an action (or function) associated with those keywords. Here, each testing action like starting or closing of browser, mouse click, keystrokes and many others, is represented by a keyword such as open_browser, click_button, Type_text and so forth [6]. Genetic algorithms are applied in various fields of biology, computer science and engineering, chemistry, manufacturing, mathematics, medicine and other fields and have many advantages and disadvantages [4]. 2. REQUIREMENTS OF KEYWORD DRIVEN FRAMEWORK In order to develop a Keyword driven Testing framework, the following things are needed: Excel Sheet- the keywords are identified and stored in an excel sheet. Function Library- Function library contains the functions for the business flows (login button for any website).so when test is executed, it will read the related keyword from the Excel file and call the functions accordingly [7]. Data Sheets- Data sheets are used to store the data that will be used to test the application. POI: Poor Obfuscation Implementation is an API provided by Apache so that different applications of MS Office can be manipulated programmatically. Object Repository- based on the keyword driven framework, an object repository will contain the data like locators of the web elements called objects. POM: Page Object Model is a design pattern of writing the code in which we specify the element of a form within a separate class file known as Object Repository. By using this framework, it is easy to manage the code and it provides us the reusability code also. Test or Driver Scripts- Based on the design of testing framework, there can be test scripts for each manual test case or a single driver script [2]. 3. INCORPORATING DATA DRIVEN TESTING IN KEYWORD DRIVEN TESTING A data driven framework where test input and output values are read from data files and are loaded into variables. The test case is contained in the data file and not in the script; the script is just a driver or a delivery mechanism for the data. Data files can be flat files (.txt) or excel files (.xls/.xlsx). Example: POI. http://www.iaeme.com/ijaret/index.asp 181 editor@iaeme.com
Nisha Jha and Rishu Gulati 3.1. Advantages of Data Driven Framework 1. Script may be developed while application development is still in progress. 2. Utilizing a modular design and using files to both input and verify data, reduces redundancy and duplication of effort in creating automated test scripts. 3. Data input/output and expected results are stored as easily maintainable text records. 3.2. Disadvantages of Data Driven Framework 1. It requires proficiency in the scripting language used by the tool i.e. technical expert. 2. Multiple data files are required for each test case. 3. Tester must not only maintain the detailed test plan with specific data, but must also re-enter this data in the various required data files. Keyword Driven Testing requires the development of data tables and keywords, independent of the test automation tool used to execute them and the test script code that drives the AUT and the data. Keyword driven tests look very similar to manual test cases. In a keyword driven test, the functionality of the AUT is documented in a table as well as in step-by-step instructions for each test. 3.3. Advantages of Keyword Driven Framework 1. The detailed test plan can be written in spreadsheet format containing all input and verification data. 2. The tester can use the automated Test Tool immediately, without needing to learn the scripting language [12]. 3. The tester need only learn the keywords required and the specific format to use within the test plan. This allows the tester to be productive with the test tool very quickly. 3.4. Disadvantages of Keyword Driven Framework 1. If the application requires more than a few customized utilities, this will require the tester to learn a number of keywords and special formats. 2. This can be time consuming. And may have an initial impact on Test Plan Development [13]. 3. More specific logics to make test cases robust cannot be added to test scripts. The most commonly used technique uses a combination of both the approaches called Hybrid method. It allows using their strengths and tries to mitigate their drawbacks. 4. ACTIVITIES DURING KEYWORD DRIVEN TESTING Keyword based testing can be carried out in both methods, manually in addition to automatic. But commonly, it's far used with automatic testing. Each keyword has to be coupled with atleast one command, test scripts or functions that implement the actions involving that keyword. When test cases are executed, keywords are interpreted by a test library, which is known by a test automation framework. The major activities involved in keyword driven testing are [4]: 1. Identifying low level as well as high-level keywords 2. Implementing the keywords as executable 3. Developing test cases 4. Developing the driver scripts 5. Executing the automation test scripts http://www.iaeme.com/ijaret/index.asp 182 editor@iaeme.com
Keyword Driven Testing Framework Using Selenium Webdriver 5. IMPLEMENTATION OVERVIEW In this section, keyword driven automation framework has been designed in Selenium Webdriver with java along with an example (http://labqashop.qacampus.com) [5]. TestNG is used as a test execution framework which uses various annotations preceded by @ symbol. It allows to group test methods easily and allows parallel testing also [17]. The following terminologies are used whine defining a test scenario and test case templates: TS_ID represents a unique number assigned to the test scenario. Test Scenarios are high level test cases, designed to represent both typical and unusual situations that may emerge while testing an application. Once test scenarios are designed, they are tested for the correctness [16]. Test Scenario Description is the description of the test scenario to be used for test case preparation. TC_ID is a unique id assigned to the corresponding test case. A test case is a set of conditions that are applied against the feature of an application to determine whether it is correctly working or not. Table 1 shows the Test Scenarios to be automated for the website labqashop. TS_ID Description TS_01 User should be able to launch site TS_02 User should be able to login with valid details TS_03 User should be able to register TS_04 User should be able to place an order The login page consists of two fields: username as email address and password which are used to authenticate the user to perform various functions like placing an order, updating his profile, give reviews and ratings and many more. The following snapshot (Figure 1) shows the login scenario for the website labqashop. Figure 1 Snapshot for Login scenario http://www.iaeme.com/ijaret/index.asp 183 editor@iaeme.com
Nisha Jha and Rishu Gulati Table 2 shows the test cases and the keywords corresponding to the Test Scenarios of the website labqashop. Here, the keywords represent the actions associated with each test case. TS_ID TC_ID Description Keyword TS_01 TC_01 user will enter the site name in address bar to launch the site launch TS_02 TC_02 user will enter the site name in address bar to launch the site launch TS_02 TC_03 user will enter the valid login id and password to login login TS_02 TC_04 user will be able to sign off on clicking the sign off link sign off TS_03 TC_05 user will enter the site name in address bar to launch the site launch TS_03 TC_06 user will enter the valid login id and password to login login TS_03 TC_07 after entering all details user should be able to place the order booking TS_03 TC_08 user will be able to sign off on clicking the sign off link sign off TS_04 TC_09 user will enter the site name in address bar to launch the site launch TS_04 TC_10 user should be able to register itself register Table 3 shows the Test data for login of the website labqashop. Username Password nishajha1992@gmail.com nisha@123 rekhajha1969@gmail.com rekha@123 neerajjha@icloud.com neeraj#03 abc@gmail.com abc rcj1989@yahoo.com rcj@123 The test data sheet in Selenium Webdriver framework contains username and password for the registered users. If the username and password are incorrect, the user will be shown an error message asking to re-enter correct details. 5.1. Selenium WebDriver in java The following WebDriver driver instance is created to execute the test cases [3]: WebDriver fd=new FirefoxDriver(); fd.get("http://labqashop.qacampus.com/"); Main Driver script in Selenium WebDriver is the main method and starting point for the framework code [14]. It reads the test cases from the data sheet one row at a time and execute the method corresponding to the current step in test case file. 5.2. Simulation results and discussion Figure 2 shows the output for login method executed in Selenium WebDriver with the above user data. The result displays all the invalid credentials with the status PASSED. Figure 2 Invalid credentials for login. http://www.iaeme.com/ijaret/index.asp 184 editor@iaeme.com
Keyword Driven Testing Framework Using Selenium Webdriver There is no failure and the test method has run for one time for all the above user detail. In this framework, keywords are developed equivalent to a unit level functionality. It is an independent framework which perform automation supported keywords specified in the excel file. Based at the type of utility, the quantity of keywords will be increased to handle specific functionalities. 6. CONCLUSIONS Selenium Webdriver has emerged as one of the best testing tool available for web application [9]. In this paper, the keyword driven testing approach has been used to perform automation testing of web application. The predominant advantage of keyword driven framework is Reusability, The same methods can be re-used for a variety of test cases. The framework can be extended by increasing flexibility with minimum effort. REFERENCES 1. P.Nirmaladevi,K.Rajeswar, Effective Automating testing with -web application Using selenium, International Journal of Communications and Engineering,Vol-5,NO.5,pp 40-46,2012. 2. Anujajain, S. Prabu, Swarnalatha, Web-Based Automation testing Framework, International Journal of Computer Applications,Vol 45,pp1-5,2012. 3. Sherry Singla, Harpreet Kaur, Selenium Keyword Driven Automation Testing Framework, International Journal of Advanced Research in Computer Science and Software Engineering, Volume 4, Issue 6, June 2014 4. Wikipedia. Keyword driven testing Wikipedia, The Free Encyclopedia. https://en.wikipedia.org/wiki/keyword-driven_testing, 2017. [Online; accessed 11-October- 2016]. 5. Qashop. http://labqashop.qacampus.com/, 2017. [Online; accessed 08-December-2016]. 6. Keyword Driven Framework Testing. http://www.guru99.com/keyword-driven-testing.html, 2017. [Online; accessed 12-January-2017]. 7. Selenium Hq Browser Automation Documentation. http://www.seleniumhq.org/. [Online; accessed 12-November-2016]. 8. R.S.Pressman, Software Engineering A Practitioner s Approach, Oxford University Press International Edition, ISBN-13:978-0-19-80-6184-7. 9. Naresh Chauhan, Software Testing Principles and Practices, McGraw-Hill International Edition, ISBN 007-124083-7. 10. Harpreet Kaur and Sherry Singla Selenium Keyword Driven Automation Testing framework in International Journal of Advanced Research in Computer Science and Software Engineering. 11. Chandraprabha, Ajeet Kumar, Sajal Saxena, Data Driven Testing Framework using Selenium WebDriver, International Journal of Computer Applications, Volume 118 No. 18, May 2015 http://www.iaeme.com/ijaret/index.asp 185 editor@iaeme.com
Nisha Jha and Rishu Gulati 12. Sanjeev Gupta, Sunil Kumar, Chirag Saxena, Review Paper on Comparison of Automation Testing Tools Selenium and QTP, International Journal of Computer Science and Information Technology, Vol. 5, No. 2, August 2015, pp. 55-57 13. Harpreet Kaur, Dr.Gagan Gupta, Comparative Study of Automated Testing Tools: Selenium, Quick Test Professional and Testcomplete, International Journal of Engineering Research and Applications, Vol. 3, Issue 5, Sep-Oct 2013, pp.1739-1743 14. Niranjanamurthy M, Arun Kumar R, Sahana Srinivas, Manoj RK, Research Study on Web Application Testing using Selenium Testing Framework,, International Journal of Computer Science and Mobile Computing, Vol.3 Issue.10, October- 2014, pg. 121-126 15. Revathi.K, Prof.V.Janani, Selenium Test Automation Framework In On-Line Based Application, International Journal of Advance Research In Science And Engineering h, Vol. No.4, Special Issue (02), February 2015 16. Himanshi, Nitin Umesh, Amar Saraswat, Automation Testing: An Introduction to Selenium, International Journal of Computer Applications, Volume 119 No.3, June 2015 17. Satish Gojarea, Rahul Joshib, Dhanashree Gaigawarec, Analysis and Design of Selenium WebDriver Automation Testing Framework, 2nd International Symposium on Big Data and Cloud Computing (ISBCC 15), http://www.iaeme.com/ijaret/index.asp 186 editor@iaeme.com