Automated Web Tests withselenium2

Similar documents
But before understanding the Selenium WebDriver concept, we need to know about the Selenium first.

SELENIUM. Courses Offered. Ph: / Course Coverage:- Date:..Timings.. Duration Fees. Testing Tools QTP Load Runner Hadoop

@AfterMethod

Koenig Solutions Pvt. Ltd. Selenium with C#

Java Lounge. Integration Solutions madeeasy ComparisonofJava Integration Frameworks. Mario Goller

Selenium. Duration: 50 hrs. Introduction to Automation. o Automating web application. o Automation challenges. o Automation life cycle

The age of automation is going to be the age of 'do it yourself. - Marshall McLuhan

Introduction to Automation. What is automation testing Advantages of Automation Testing How to learn any automation tool Types of Automation tools

CENTRALIZED UI AUTOMATION FOR SAAS APPLICATION

OSSW ICOSST 2009, Al-Khawarizmi Institute of Computer Science University of Engineering and Technology, Lahore

1. Selenium Integrated Development Environment (IDE) 2. Selenium Remote Control (RC) 3. Web Driver 4. Selenium Grid

SELENIUM. SELENIUM COMPONENTS Selenium IDE Selenium RC Selenium Web Driver Selenium Grid

What is the Selendroid?

ActiveNET Enterprise Solution Company

Mind Q Systems Private Limited

Selenium WebDriver Interview Questions & Answers

Testing Masters Technologies. Selenium FAQs

Selenium Testing Course Content

A faster approach for accessing Snap Deal URL using Multi browser with Selenium Web Driver

This is one of the common interview questions in any Automation testing job.

Selenium Testing Training

Manual Testing. Software Development Life Cycle. Verification. Mobile Testing

Sichere Software vom Java-Entwickler

SeU Certified Selenium Engineer (CSE) Syllabus

Selenium Training. Training Topics

Learning Objectives of CP-SAT v 1.3

International Journal of Advance Engineering and Research Development. Proof of concept (Poc) selenium web driver based Automation framework

SeU Certified Selenium Engineer (CSE) Syllabus

REALTIME WEB APPLICATIONS WITH ORACLE APEX

Learning Objectives of CP-SAT v 1.31

STQA Mini Project No. 2

Learning Objectives of CP-SAT v 1.31 (C#)

1. SUPPORT PLATFORMS 2. INSTALLATION GUIDE Install Android SDK

Getting Started with Appium

Java Programming Basics

Software Testing

[paf Wj] open source. Selenium 1.0 Testing Tools. Beginner's Guide. using the Selenium Framework to ensure the quality

SELENIUM - REMOTE CONTROL

Testing => Good? Automated Testing => Better?

Selenium Webdriver Github

All About Cranking Out High Quality XPages Applications. Martin Donnelly IBM Ireland

Welcome to the OWASP TOP 10

Apache Tamaya Configuring your Containers...

QMS ISO 9001:2015 CERTIFIED COMPANY Software Testing TRAINING.

AN ISO 9001:2008 CERTIFIED COMPANY. Software Testing TRAINING.

Sahi. Cost effective Web Automation

Selenium Web Test Tool Training Using Ruby Language

BY: ATASHI SAMADDAR 1

Class 1 Introduction to Selenium, Software Test Life Cycle.

webdriver selenium 08FE064A22BF82F5A04B63153DCF68BB Webdriver Selenium 1 / 6

MANUAL+ SELENIUM CURRICULUM

SELENIUM TRAINING COURSE CONTENT

Oracle Access Management

Appium mobile test automation

Google Wave Client: Powered by GWT. Adam Schuck 28 May, 2009

BrowseEmAll Documentation

MultiBrowser Documentation

Service discovery in Kubernetes with Fabric8

Been testing software for over 10 years Started out as a Manual Tester Moved to Automation testing Now leading teams, defining quality in

(Complete Package) We are ready to serve Latest Testing Trends, Are you ready to learn? New Batches Info

SeleniumJava Training Solution

Selenium Course Content

EXPERT TRAINING PROGRAM [Selenium 2.0 / WebDriver]

Introduction: Manual Testing :

Social Media Testing with Selenium

Topic 16: Validation. CITS3403 Agile Web Development. Express, Angular and Node, Chapter 11

Integration of Oracle VM 3 in Enterprise Manager 12c

AUTOMATION FOR APPS 1

13 th Annual International Software Testing Conference in India 2013

AUTOMATION TESTING FRAMEWORK FOR LUMINOUS LMS

Chrome if I want to. What that should do, is have my specifications run against four different instances of Chrome, in parallel.

SeeTest Quality Assurance Platform SeeTestAutomation

Test-driven development

Mischa Kölliker. JavaLounge Zürich, 23. Juni 2009

Enabling Mobile Automation Testing using Open Source Tools

Mobile Testing. Open Source Solu,ons

*** Any Query *** Mail : 1. Introduction to Selenium. What is Selenium? Different automations tools. Selenium Automation Tools

Behavior- Driven Testing Using Page Object Models

Get Groovy with ODI Trivadis

CHICAGO. How to Tackle Open Source Test Automation in Incredible Ways. Renaissance Hotel 1 West Wacker Drive Chicago IL April 18th April 22th

User Documentation: Job Aid. SynerTrade Tendering/RFx. Supplier Quick Reference Guide

Telerik Test Studio. Web/Desktop Testing. Software Quality Assurance Telerik Software Academy

End-to-End Test and Build

Test Automation Integration with Test Management QAComplete

Scripting OBIEE Is UDML and XML all you need?

Query Optimizer MySQL vs. PostgreSQL

C# 2013 Express Web WebDriver Automation. Introduction tutorial

(Complete Package) We are ready to serve Latest Testing Trends, Are you ready to learn? New Batches Info

Maja Schreiner. 9th Lean, Agile & Scrum Conference 2017

Best Practices for Testing SOA Suite 11g based systems

Tivoli Common Reporting V Cognos report in a Tivoli Integrated Portal dashboard

Test Automation of UI Tests using Selenium and Appium

Query Optimizer MySQL vs. PostgreSQL

Test Automation Integration with Test Management QAComplete

Technology. Business Objectives & Challenges. Overview. Technical Solution

Bloom Filters DOAG Webinar, 12 August 2016 Christian Antognini Senior Principal Consultant

LIVE WEBINAR: MOBILE TESTING WITH APPIUM HOW TO MODIFY YOUR TESTS TO RUN ON ios10?

SeeTest Quality Assurance Platform On-premise Digital Assurance Lab

SOLVING THE MOBILE TESTING CONUNDRUM

Test Engineer Expert Course

Transcription:

Automated Web Tests withselenium2 Java Forum Stuttgart 2013 Mario Goller Trivadis AG BASEL BERN LAUSANNE ZÜRICH DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MÜNCHEN STUTTGART WIEN 1

AGENDA 1. Selenium & WebDriver 2. Locating Elements 3. User Interactions 4. Page Objects 5. Selenium GRID 6. Testing on Mobile Devices 2

Selenium History Started in 2004 in by Jason Huggins who worked in ThoughtWorks (originated from TW Time Sheet application) Jason joins Google in 2007 Currently CTO of SauceLabs Simon Stewart Started work on WebDriver in Google http://google-opensource.blogspot.in/2009/05/introducing-webdriver.html 3

Who uses Selenium 4

Challenges Language/ Framework Browser Platform 5

Challenges SCRUM XP 6

Advantages of Test Automation Frequent and quick regression testing Rapid feedback to developers Virtually unlimited iterations of test case execution Support for Agile and extreme development methodologies Increased test coverage Enables QA team to utilize bandwidth in exploratory testing. 7

What is Selenium? 8

What is Selenium? Selenium IDE Selenium RC Selenium GRID Selenium Core (WebDriver) 9

Selenium IDE Firefox plug-in Integrated Development Environment for Selenium Tests. Provides record and playback functionality. Provides the ability to debug test scripts. Auto complete common selenium commands Export tests in different formats like Ruby, Python, JUnit so on. Supports user extensions 10

Selenium Versions Selenium 1 JavaScript Browser Web Page Test Selenium RC Client Selenium RC Server Selenium Core JavaScript Native bindings HTTP HTTP Selenium 2 Test Selenium 2 Browser Native bindings Browser native bindings 11

Selenium 2 (WebDriver) Object Oriented, smaller, compact API make it easier to work with compared to RemoteControl Mimics the way that your users work with your site and apps Offers advanced user interactions APIs Drag and Drop Clicking multiple elements with Control key 12

Selenium WebDriver ChromeDriver InternetExplorerDriver FirefoxDriver OperaDriver AndroidDriver iphonedriver RemoteWebDriver Support for WebDriveris baked into the browser itself: your tests run fast and are stable 13

Selenium WebDriver Set up the WebDriverin JUnit @Before public void setup() throws Exception { driver = new FirefoxDriver(); baseurl = "http://www.myapp.com/"; driver.manage().timeouts().implicitlywait(30, TimeUnit.SECONDS); } @Before public void setup() throws Exception { driver = new InternetExplorerDriver();... } @Before public void setup() throws Exception { driver = new ChromeDriver();... } 14

AGENDA 1. Selenium & WebDriver 2. Locating Elements 3. User Interactions 4. Page Objects 5. Selenium GRID 6. Testing on Mobile Devices 15

Locating Elements ByID driver.findelement(by.id(<element ID>)) Byname driver.findelement(by.name(<element name>)) Byclassname driver.findelement(by.classname(<element class>)) Bytag name driver.findelement(by.tagname(<htmltagname>)) ByCSS / XPath driver.findelement(by.cssselector(<css selector>)) driver.findelement(by.xpath (<xpath query expression>)) 16

AGENDA 1. Selenium & WebDriver 2. Locating Elements 3. User Interactions 4. Page Objects 5. Selenium GRID 6. Testing on Mobile Devices 17

Page Interactions webelement.click() webelement.sendkeys(...) webelement.submit() Actions class-> Mouse Events / Drag anddrop @Test public void testdragdrop() { WebElement source = driver.findelement(by.id("draggable")); WebElement target = driver.findelement(by.id("droppable")); } Actions builder = new Actions(driver); builder.draganddrop(source, target).perform(); try { assertequals("dropped!", target.gettext()); } catch (Error e) { verificationerrors.append(e.tostring()); } 18

AGENDA 1. Selenium & WebDriver 2. Locating Elements 3. User Interactions 4. Page Objects 5. Selenium GRID 6. Testing on Mobile Devices 19

Using Page Objects Consolidates the code for interaction with any give UI element Login Page AllowsoutomodeltheUI in yourtests Exposesmethodsthatreflectthethingsa usercanseeanddo on thatwebpage LoginPage Class @Test public void testlogin() throws Exception { LoginPage loginpage = new LoginPage(driver); HomePage homepage = loginpage.loginas("peter", "secure"); assertequals("welcome",homepage.gettitle()); } Test (JUnit) 20

Page Object - Example public class LoginPage { private final WebDriver driver; @FindBy(id="button_submit") public WebElement submitbutton; public LoginPage(WebDriver driver) { this.driver = driver;... } public HomePage loginas(string username, String password) { executelogin(username, password); return new HomePage(driver); } } private void executelogin(string username, String password) { driver.findelement(by.id("field_username")).sendkeys(username); driver.findelement(by.id("field_password")).sendkeys(password); submitbutton.submit(); } 21

Advanced Topics Execute JavaScript JavascriptExecutor js = (JavascriptExecutor) driver; String title = (String) js.executescript("return document.title"); assertequals("google", title); Taking Screenshots @Test public void testtakesscreenshot() { try { File scrfile = ((TakesScreenshot) driver).getscreenshotas(outputtype.file); FileUtils.copyFile(scrFile, new File("c:\\tmp\\main_page.png")); } catch (Exception e) { e.printstacktrace(); } } 22

AGENDA 1. Selenium & WebDriver 2. Locating Elements 3. User Interactions 4. Page Objects 5. Selenium GRID 6. Testing on Mobile Devices 23

Selenium GRID Parallelizing tasks Unit ofwork Servers Time 24

WhatisSeleniumGrid? Maintain a cluster of Selenium nodes Configure tests for different environments (Browser/Platform) Parallelize your tests 25

Start up the Selenium Hub Prerequisites: A Java 5+ JRE selenium-server-standalone.jar $ java jar selenium-server-standalone.jar role hub Three options (in order of precedence): Grid 1 compatible YAML file JSON configuration file Command-line flags View current hub config in console (Click View Config link) 26

The Selenium Grid Console Web console to see grid state and config: Open a web browser to: http://localhost:4444/grid/console Beta console available at: http://localhost:4444/grid/beta/console 27

Startingupa Node Prerequisites: A Java 5+ JRE selenium-server-standalone.jar Run: $ java jar selenium-server-standalone.jar role node hubhost localhost Two options (in order of precedence): JSON configuration file Command-line flags View current config in beta console (Click Configuration tab for node 28

RemoteWebDriver public void mytest() throws Exception { } //FirefoxProfile fp = new FirefoxProfile(); //DesiredCapabilities dc = DesiredCapabilities.firefox(); //dc.setcapability(firefoxdriver.profile, fp); ChromeOptions options = new ChromeOptions(); DesiredCapabilities dc = DesiredCapabilities.chrome(); dc.setcapability(chromeoptions.capability, options); WebDriver driver = new RemoteWebDriver(dc); WebDriver driver = new RemoteWebDriver(new URL( "http://localhost:4444/wd/hub"), DesiredCapabilities.firefox()); driver.get("http://www.google.com"); 29

Parallelizing Tests Grid helps you organize resources and spread load but you still need to parallelize your tests TestNG makes this pretty straightforward Works also for JUnit: See article Adam Goucher wrote for SauceLabs s blog 30

Multi-Browser Parallel Testing public class ParallelRunning { private WebDriver driver = null; } @BeforeTest @Parameters({ "BROWSER" }) public void setup(string BROWSER) { if (BROWSER.equals("FF")) { driver = new FirefoxDriver(); } else if (BROWSER.equals("IE")) { driver = new InternetExplorerDriver(); } else if (BROWSER.equals("CH")) { driver = new ChromeDriver(); } } @Test public void testparallel() throws Exception { driver.get("http://www.google.com");... driver.quit(); } TestNG <suite name="webdriver" parallel="tests"> <test name="webdriverdemo Witn FF" preserveorder="true"> <parameter name="browser" value="ff" /> <classes> <class name="com.web.parallelrunning" /> </classes> </test> <test name="webdriverdemo with IE" preserveorder="true"> <parameter name="browser" value="ie"></parameter> <classes> <class name="com.web.parallelrunning"></class> </classes> </test> </suite> 31

AGENDA 1. Selenium & WebDriver 2. Locating Elements 3. User Interactions 4. Page Objects 5. Selenium GRID 6. Testing on Mobile Devices 32

Testing Mobile Devices with Robots? Bitbeambot(http://bitbeam.org) 33

BitbeamBot An open source hardware CNC robotfor testing applications on mobile device Why? BitbeamBotis an experiment to take Selenium out of the screen and into the real world. Selenium is a software-based robot Selenium mimics and automates how users interact with an application For mobile, this means handling real devices 34

Mobile Testing with Selenium How to 35

Mobile Testing with Selenium Create AVD $./androidcreateavd-n my_android-t 8 -c 100M Start Emulator $./emulator-avd my_android-no-audio -no-boot-anim-scale.8 & Install Selenium APK $ cd ~/android_sdk/platform-tools/ $./adb-e install-r ~/selenium/android/prebuilt/android-server.apk $./adb forward tcp:8080 tcp:8080 36

Mobile Testing with Selenium Launch the WebDriver App: 37

Selenium-Why to use? Communicate with browsers in 'native' way via drivers Not limited to JavaScripts For example: upload files, work with popups, iframes etc. Support for a lot of browsers including mobile phone browsers Support many languages, including Java, C#, Ruby, Python and so on Free & Open Source!!! 38

Selenium & Continuous Integration Run Selenium tests as part of the build Works with both Core and Driven modes (each time a developer checks in) Can generate HTML reports, published to team members Helps catch bugs ASAP Addresses risk of catching bugs late in the cycle 39

Questions? 40

THANK YOU. Trivadis AG Mario Goller Europastrasse 5 CH-8152 Glattbrugg(ZH) Tel. +41-44-808 70 20 Fax +41-44-808 70 21 info@trivadis.com www.trivadis.com BASEL BERN LAUSANNE ZÜRICH DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MÜNCHEN STUTTGART WIEN 41