WebDriver: Controlling your Web Browser

Similar documents
TESTING WEB SERVICES WITH WEBDRIVER AND QUICKCHECK

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

ActiveNET Enterprise Solution Company

webdriver selenium 08FE064A22BF82F5A04B63153DCF68BB Webdriver Selenium 1 / 6

Selenium Testing Course Content

GuideAutomator: Automated User Manual Generation with Markdown

Class 1 Introduction to Selenium, Software Test Life Cycle.

CSCI 1320 Creating Modern Web Applications

Web testing at Corporama

Selenium Webdriver Github

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

Changing The User Agent String In Safari User Guide For Web Developers

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

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

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

13 th Annual International Software Testing Conference in India 2013

STQA Mini Project No. 2

Selenium Training. Training Topics

EPHP a tool for learning the basics of PHP development. Nick Whitelegg School of Media Arts and Technology Southampton Solent University

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

Selenium Course Content

BrowseEmAll Documentation

MultiBrowser Documentation

Testing => Good? Automated Testing => Better?

Checklist for Testing of Web Application

AUTOMATION FOR APPS 1

Browser-Related Issues Clearing Cookies and Cache

PCC Local File Viewer User Guide. Version /23/2015 Copyright 2015

Selenium vs UFT: Which is Better for Your Mobile Testing Strategy?

selenose Documentation

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

SELENIUM TRAINING COURSE CONTENT

Scraping Sites that Don t Want to be Scraped/ Scraping Sites that Use Search Forms

Web Application Performance Testing with MERCURY LOADRUNNER

Testing. Wouter Swierstra and Alejandro Serrano. Advanced functional programming - Lecture 2. [Faculty of Science Information and Computing Sciences]

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

Read & Download (PDF Kindle) Selenium WebDriver Practical Guide

How to Configure an SSH Tunnel on PuTTY

Getting Started with Appium

HOW TO SUBMIT AN ASSIGNMENT

Building video apps on Salesforce Platform

OAuth 2 and Native Apps

What is the Selendroid?

Using OAuth 2.0 to Access ionbiz APIs

@AfterMethod

IBM Website Monitoring Response Time

Koenig Solutions Pvt. Ltd. Selenium with C#

iphone ios 8.x (4s, 5, 5s & 5c, 6, 6+ models) ipad ios 8.x (all models) Android OS or higher

webbot Documentation Release Natesh M Bhat

Test Driven Development and Refactoring. CSC 440/540: Software Engineering Slide #1

ERP Student Manual. Contents

QMS ISO 9001:2015 CERTIFIED COMPANY Software Testing TRAINING.

Instructor s Notes Web Data Management Web Client/Server Concepts. Web Data Management Web Client/Server Concepts

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

XCOLD Information Leak

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

SELENIUM - REMOTE CONTROL

604: Automating NetScaler Deployments and Monitoring using the NetScaler 10.5 NITRO API Hands-on Lab Exercise Guide

Automated Web Application Testing Using Selenium

NIELSEN API PORTAL USER REGISTRATION GUIDE

Xcode Encountered An Internal Logic Error >>>CLICK HERE<<<

Attack Surface Intelligence of Source Code

Contents. Last updated: 18 th August 2017

The Software Delivery Experts. Agile, DevOps & QA Conference

Clear Cache Internet Explorer 8 Window Xp 32 Bit

Tale of a mobile application ruining the security of global solution because of a broken API design. SIGS Geneva 21/09/2016 Jérémy MATOS

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

The course also includes an overview of some of the most popular frameworks that you will most likely encounter in your real work environments.

Comparative Study of Software Automation Testing Tools: OpenScript and Selenium

Acceptance Test Plan and Cases (ATPC)

HTTP Protocol and Server-Side Basics

Matrix Release Note Highlights

Microsoft IIS version 6 Integration

Software System Design and Implementation

Step 7 How to convert a YouTube Video to Music As I mentioned in the YouTube Introduction, you can convert a Video to a MP3 file using Free Video To

Protocol Buffers, grpc

Information & Communications Technologies Portal Tipsheet

Test Automation to the Limit

Scaling with Continuous Deployment

WHAT S NEW IN SELENIUM IDE 3.1?

HTTP, WebSocket, SPDY, HTTP/2.0

E-statement Settings Guide

1) What is the difference between Mobile device testing and mobile application testing?

Master Project Software Engineering: Team-based Development WS 2010/11

Clear Cache Guide Click here for Windows guide Click here for Mac OS guide

Web Programming Paper Solution (Chapter wise)

etrac Guide System Requirements Global DMS, 1555 Bustard Road, Suite 300, Lansdale, PA , All Rights Reserved.

FreeRangeRemote Access

Solar Plant Data Acquisition Maintenance

Automated Security Scanning in Payment Industry

Learning Objectives of CP-SAT v 1.31

QuickCheck Mini for Elixir. Thomas Arts Quviq AB

Perceptive Nolij Web. Technical Specifications. Version: 6.8.x

Browser Support Internet Explorer

Manual Internet Explorer 9 Windows Xp Full. Version >>>CLICK HERE<<<

Testing for the Unexpected

CENTRALIZED UI AUTOMATION FOR SAAS APPLICATION

YU Kaltura Media Package User's Guide For version 1.1.x. Written by Media and Information Technology Center, Yamaguchi University.

Chrome and IE comparisons

Restful Interfaces to Third-Party Websites with Python

Transcription:

WebDriver: Controlling your Web Browser Erlang User Conference 2013 Hans Svensson, Quviq AB hans.svensson@quviq.com

First, a confession... I have a confession to make... I have built a web system! In PHP!... and it was painfully mundane to test It is all forgotten and forgiven... It was back in 2003!

First DEMO DEMO

A bit of history Proving program correctness Erlang Reality a constant issue PhD student Testing is necessary

A bit of history Proving program correctness Erlang Reality a constant issue PhD student Testing is necessary

We like to write our properties in QuickCheck How can we control a browser from Erlang? Doing it all from scratch seems hard, unnecessary, stupid,...

Selenium Selenium automates browsers. That's it. What you do with that power is entirely up to you. Primarily it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should!) also be automated as well.

Selenium Basically you can create and run scripts Supported by a wide range of browsers and operating systems Run tests in: Chrome, IE, Opera, Firefox, and partial support also for other browsers. Runs on: Windows, OS X, Linux, Solaris, and others. Script recording using Selenium IDE (Firefox plugin). Language support for: C#, Java, Python, Ruby, and partial support for Perl and PHP. Widely used to create Unit-tests and regression testing suites for web services.

Selenium 2 - WebDriver In version 2, Selenium introduced the WebDriver API Via WebDriver it is possible to drive the browser natively The browser can be local or remote possible to use a grid test It is a compact Object Oriented API Supports Chrome, Firefox, HtmlUnit, Opera, IE, and IPhone and Android Languages implementing driver: C#, Java, Python, and Ruby.

WebDriver Wire Protocol What if your preferred language is not in the list? All WebDriver drivers communicates via HTTP using the WebDriver Wire Protocol It is a RESTful web service using JSON over HTTP The Wire Protocol consists of ~80 different commands controlling different aspects such as: Windows/Tabs open, close, resize, set_position, maximize,... Page elements find, find relative, click, send_keys, submit,... Navigation back, forward, refresh, set_url,... Timeouts script timeout, page load timeout,... Cookies set, get, delete,...

WebDriver in Erlang Implementation consists of webdrv_cap handle web browser capabilities webdrv_wire purely functional implementation of the wire protocol webdrv_session wrapper module for WebDriver sessions json JSON library, written by Tony Garnock-Jones http://github.com/tonyg/erlang-rfc4627

webdrv_wire 77> webdrv_wire:get_status( #webdrv_opts{url = "http://localhost:9515/"}). {ok,<<>>,{obj,[{"build",{obj,[{"version",<<"alpha">>}]}}, {"os",{obj,[{"arch",<<"x86">>}, {"name",<<"linux">>}, {"version",<<"3.2.0-43-generic">>}]}}]}} 78> webdrv_wire:start_session( #webdrv_opts{url = "http://localhost:9515/"}, webdrv_cap:default_chrome()). {ok,<<"81892cb363f177b6b7a90d40e646c924">>, {obj,[{"acceptsslcerts",true}, {"applicationcacheenabled",false}, {"browserconnectionenabled",false}, {"browsername",<<"chrome">>},... ]}} 79> webdrv_wire:set_url( #webdrv_opts{url = "http://localhost:9515/", session_id = "81892cb363f177b6b7a90d40e646c924" }, <<"http://google.se">>). {ok,<<"81892cb363f177b6b7a90d40e646c924">>,null} Ouch! That is a lot of typing...

webdrv_session 93> webdrv_session:start_session( test, "http://localhost:9515/", webdrv_cap:default_chrome()). {ok,<0.3045.0>} 94> webdrv_session:set_url(test, "http://google.se"). ok 95> {ok, E} = webdrv_session:find_element(test, "name", "q"). {ok,"0.4722895685117692:1"} 96> webdrv_session:send_value( test, E, "Erlang User Conference 2013"). ok 97> webdrv_session:submit(test, E). ok 98> webdrv_session:get_page_title(test). {ok,"erlang user conference 2013 - Sök på Google"}

It is on GitHub https://github.com/quviq/webdrv Makefile make release creates webdrv-1.0, copy it to <erlang>/lib to install MIT license

QuickCheck Originally developed by John Hughes and Koen Claessen Property based testing Controlled randomness Shrinking QuickCheck libraries in many languages

Quviq - QuickCheck Written in Erlang Many extensions: Statem: testing using finite state machines PULSE: finding race conditions Symbolic test case generation Mocking (C and Erlang) Testing C-code Composable components

Testing WebDriver with QuickCheck We can combine QuickCheck and WebDriver Insert data generators Use QuickCheck (finite) state machine to store system state generate valid sequences of WebDriver calls Rely on shrinking to find minimal counterexample Play back a counterexample The tests used: Chrome, Firefox, and HtmlUnit The tests used: Selenium Server 2.33.0, and Chromedriver 2 (r202239)

What did we find? How hard can it be to follow a specification? Answer: Very hard!

Problem I Selenium 302 redirect Problem: When creating a new session (doing a POST request), Selenium answers with a 302 redirection. From specification: Returns: A 303 See Other redirect to /session/:sessionid, where :sessionid is the ID of the newly created session.

Prob. II Chromedriver case sensitive headers Problem: Certain parameters in a HTTP POST request are ignored by Chromedriver. If they are passed with the expected capitalization it works. RFC 2616: Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive.

Prob. III httpc_request is broken in OTP/R15 Problem: When getting a 303 See Other, from Chromedriver, {autoredirect, true} fails to automatically redirect. RFC 2616, 10.3.4: The response to the request can be found under a different URI and SHOULD be retrieved using a GET method on that resource. Fixed in R16, but more problems arose...

Prob. IV Maximizing a window twice hangs Problem: When using Chromedriver, maximizing a window twice hangs the WebDriver session. DEMO

Prob. IV Maximizing a window twice hangs set_window_maximize({session, Window}) -> webdrv_session:set_window_maximize(session, Window). set_window_maximize_args(s) ->[session_and_window(s)]. set_window_maximize_pre(s, [{Sess, _Window}]) -> #session{ browser = B, driver = D, maximized = M } = get_session(s, Sess), %% Bug in chromedriver used by selenium. not M orelse B /= chrome orelse D /= selenium. set_window_maximize_next(s, _V, [{Sess, _Win}]) -> Win = get_curr_window(s, Sess), set_window(s, Sess, Win#window{ size = undefined, position = undefined, maximized = true}). set_window_maximize_post(_s, [{_Sess, _Win}], Res) -> eq(res, ok).

Prob. IV Maximizing a window twice hangs Problem: When using Chromedriver, maximizing a window twice hangs the WebDriver session. Fixed in Chromedriver 2

Prob. V Chromedriver 2 screenshot fails Problem: If you open a second window/tab, and then focus back on the first window, grabbing a screenshot of that window fails. If we close the second window (in the background) a screenshot can be taken! The power of QuickCheck: No (sane) tester would write this (unit) test case. (In fact the first non-shrunk test case involved three windows and several re-focusing operations...)

Other problems and quirks Timeouts/2 not implemented - Fixed Get window size/position fails if multiple tabs (=windows) are open. Not reporting errors consistently (get_window_size/ postition + others) Inconsistent error reporting 'UnknownError'/'NoSuchElement'

The way forward Write traditional QuickCheck models of web service API Write utility libraries on top of webdrv_session Integrate with Selenium IDE converting test cases into Erlang EUnit tests Automatically derive a state machine specification from a set of EUnit tests

Using recorded tests in Erlang Test cases can be recorded in Selenium IDE (only available for Firefox) Reasonably straightforward to translate a test case into a sequence of webdrv_session calls Wrapping it as an EUnit test or a simple QuickCheck property

Deriving state machines from EUnit tests Earlier research have looked into automatic generation/derivation of state machines Input is a set of tests, output is a state machine describing the set of tests Could be a cheap way to get started with a QuickCheck model of a web service

Try it! Break it! Fix it! Try using it If it breaks, fix it! https://github.com/quviq/webdrv