How to Tackle Open Source Test Automation in Incredible Ways CHICAGO April 18th April 22th Renaissance Hotel 1 West Wacker Drive Chicago IL 60601 Speaker(s): Company: Harpreat Singh & Piyush Sachar Microexcel When: April 20, 2016 Time: 11:15 am - 12:15 pm
Selenium Demo Microexcel Inc. 400 Plaza Drive, 1st Floor Secaucus, NJ 07094 www.microexcel.com sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 1
Agenda General Selenium Automation Model Hybrid Framework Page Object Model Selenium and Cucumber Implementation Robot Framework and Selenium Appium Mobile Automation CI - Integration sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 2
General Selenium Automation Model Selenium Automation Model Eclipse Editor for writing Test Case Selenium API for automation browser JAVA Platform on which above runs sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 3
General Selenium Automation Model Two types of framework which can be implemented: Automation Framework Hybrid Framework (Data and Keyword) Page Object Model sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 4
Hybrid Automation Framework It is combination of Keyword and Data Test cases are written in Excel Suitable for non-technical users Does not require programming language knowledge for writing test cases Key Components Test Case Object Repository sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 5
Hybrid Automation Framework Eclipse (IDE) Selenium Web Driver Excel Reader Test Driver Excel Based Inputs Test Suite Test Data Object Repository Screen Capture Functional Libraries Results Business Functions Common Functions sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 6
Page Object Model Framework Based upon design pattern used for software development Models the pages/screen of application as objects Page Objects Page Objects encapsulates all functions that can be performed on page Key Components Page Class Test Cases calling function from Page Classes sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 7
Page Object Model Framework Login Page Objects Username field Password field Submit/Login button Functions Successful Login Unsuccessful Login sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 8
Page Object Model Framework Eclipse (IDE) Selenium Web Driver Test Case Login Page.SuccessfulLogin Shopping Page.SearchProduct Shopping Page.NavigatetoProduct Product Page.AddtoCart Payment Page.SetatPayment Screen Capture Results Login Page Object Definition Functions Successful Login Unsuccessful Login Shopping Page Object Definition Functions Search Product Navigate to Product Page Object Product Page Object Definition Functions Add to Cart Payment Page Object Definition Functions SetatPayment (Visa) Application Under Test sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 9
Selenium and Cucumber Implementation Cucumber is a testing framework that helps to bridge the gap between software developers and business managers Tests are written in plain language based on the behavior-driven development (BDD) Test are in the style of Given, When, Then Feature files contains test cases that cover one or more test scenarios Selenium Web Driver can be used to take advantage of above framework for browser based testing sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 10
Selenium and Cucumber Implementation Methods & Functions How to do What to do Do it Scenarios and Steps sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 11
Selenium and Cucumber Implementation What to do sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 12
Selenium and Cucumber Implementation Interpreter determines how to do with code like below How to do @Given("^I navigate to wesbite url\"$") public void I_navigate_to_wesbite_url(){ selenium.openbrowserandnavigate("<url>"); } @When("I enter valid credentails\"$") public void I_enter_valid_credentails(){ selenium.entervalidcredentails(); } @When("I should see welcome message\"$") public void I_should_see_welcome_message(){ selenium.validatemessageonpage("<welcome Message>"); } sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 13
Selenium and Cucumber Implementation Do it Calls Selenium Web Driver API s to perform actions on Web Browser For e.g. selenium.openbrowserandnavigate : Calls driver.get(<url>) Do it selenium.entervalidcredentails() : Calls driver.findelement( <element def> ).sendkeys(<text>) to enter username and password selenium.validatemessageonpage("<welcome Message>") : Calls driver.findelement( <element def> ).gettext() to verify message sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 14
Robot Framework and Selenium Robot Framework is an open source test automation framework Uses keyword-driven testing approach Support libraries developed in Python and Java It has Selenium Library which helps to automate browser Advantages Along with Selenium, support many other libraries with easy to use interface Ready made framework, so requires less turn around time to create automation suites Minimal programming language knowledge to create scripts sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 15
Robot Framework and Selenium Architecture Application Under Test Robot Framework Selenium2 Library Android Library ios Library Database Library And Many More Libraries Test Implementation (Test Suites, other resources Files like xml, Excel etc) sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 16
Robot Framework and Selenium Easy to START sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 17
Robot Framework and Selenium Easy to USE UI and existing keywords removes lot of complexity out of script creation sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 18
Robot Framework and Selenium Reporting is Bonus sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 19
Appium Implementation & Selenium Connection Appium is an open source tool for automation on Mobile devices Can automate native, hybrid and mobile apps Give flexibility in terms of selecting programming language and test framework Programming Language Java, PHP, Python, JS etc It drives ios and Android apps using WebDriver protocol Prior Selenium Knowledge on Browser automation gives instant start to creating scripts on sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 20
Appium Architecture 30000 Feet sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 21
Appium Architecture Ground Level sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 22
Identifying Element & Scripting Identifying Element -Web Browser Automation - FireBug - Mobile Automation - Appium Inspector - UIAutomator Viewer(Android) - UIAutomation(iOS) Test Scripting - Web Browser & Mobile Automation - Eclipse sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 23
Identifying Element & Scripting Appium Inspector Appium Inspector is part of appium server Start Appium and point to app to get hierarchy of elements Record and Play on apps to re-use code for scripting Works for Android and ios both Scripting is WebDriver based so very similar to browser automation sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 24
Identifying Element & Scripting Appium Inspector String app_package_name = "com.flipkart.android:id/"; By userid = By.id(app_package_name + "user_id"); driver.findelement(userid).sendkeys("someone@domain.com"); sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 25
CI Integration - Jenkins CI integration is available for all below on Jenkins General Selenium Browser Automation Cucumber Robot Framework Appium sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 26
CI General Selenium & Appium sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 27
CI - Cucumber sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 28
CI Integration Robot Framework sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 29
sales@microexcel.com Phone: 201-866-6789 www.microexcel.com 30 30