Basic Selenium Scripting Tutorial

Similar documents
Graphic Selenium Testing Tool

Automation: Simulation of any Human work by a System or a Tool is known as Automation.

VERSION JANUARY 19, 2015 TEST STUDIO QUICK-START GUIDE STANDALONE & VISUAL STUDIO PLUG-IN TELERIK A PROGRESS COMPANY

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

Telerik Corp. Test Studio Standalone & Visual Studio Plug-In Quick-Start Guide

Guide to add as trusted site in Java 8 Update 51. Version of 24 OCBC Bank. All Rights Reserved

Troubleshooting for Recorded Scripts

Title and Modify Page Properties

How to Search Using Google

Google Sheets: Spreadsheet basics

A Dreamweaver Tutorial. Contents Page

Setting up a Google Account together with Google Reader and igoogle.

This document provides a concise, introductory lesson in HTML formatting.

A Frontpage Tutorial. Contents Page

Srilu Pinjala (Sridevi) IBM

Google Sheets: Spreadsheet basics

Technical White Paper

ROES EVENTS SYSTEM TUTORIAL

HOW TO SIGN IN... 3 TRAINING FOR GOOGLE APPS... 4 HOW TO USE GOOGLE DRIVE... 5 HOW TO CREATE A DOCUMENT IN DRIVE... 6

How to broadcast in HD 720p using FMLE on cams.com

SCRIPT REFERENCE. UBot Studio Version 4. The Selectors

Interactive Tourist Map

FIREFOX MENU REFERENCE This menu reference is available in a prettier format at

Hello, welcome to this brief tutorial on accessing and playing Adobe Presenter video files.

ValuePRO Tutorial Internet Explorer 8 Configuration

Lobbyist Registration U s e r G u i d e

Premium POS Pizza Order Entry Module. Introduction and Tutorial

Getting Started Guide

Step 1: Upload a video (skip to Step 2 if you ve already uploaded a video directly from your ipod, Uploading to YouTube and Posting in Blackboard

How to Launch an Online Course for the first time

Google Docs: Spreadsheet basics

BY: ATASHI SAMADDAR 1

Harmony Touch User Guide

Task On Gingerbread On Ice Cream Sandwich Notification bar on lock screen Notification bar is not accessible on the lock screen.

Dreamweaver Publishing and Editing Files. Outline

Sync to a Secondary Salesforce Organization

How To: Advanced CMA

A demo Wakanda solution (containing a project) is provided with each chapter. To run a demo:

The UBot Studio SCRIPT REFERENCE. The Flow/Input/Variable/Qualifier Commands

Selenium IDE. Steve Kwon, Raphael Huang, Amad Hussain, Mubasil Shamim

Dreamspark HelpGuide

SSJS Server-Side JavaScript WAF Wakanda Ajax Framework

User manual. Release Notes DYNAMICWEB 7.1. Internal version number: Version: English

Citrus Valley Health Partners Citrix Client Download Instructions - V.6 Information Services

InterActive SyslogViewer Adiscon GmbH

HOW TO SIGN IN... 3 HOW TO USE GOOGLE DRIVE... 4 HOW TO CREATE A DOCUMENT IN DRIVE... 5 HOW TO SHARE A DOCUMENT (REAL TIME COLLABORATION)...

Chromebook Challenge. 20 Tips in 20 Days

In this tutorial, you will learn how to perform basic tasks for setting up a course site in Moodle.

Online App Access: Quick Set-up & Instructions

LogMeIn Rescue New Features, April 2015

Preview from Notesale.co.uk Page 2 of 82

Comodo Dragon. User Guide Guide Version Software Version Comodo Security Solutions 525 Washington Blvd. Jersey City, NJ 07310

Using Dreamweaver CC. 3 Basic Page Editing. Planning. Viewing Different Design Styles

Using Qualtrics. ERL Workshop Social Psychology Lab Spring 2014

Visual Workflow Implementation Guide

Quick XPath Guide. Introduction. What is XPath? Nodes

What do we mean by layouts?

FreeRangeRemote Access

To make Roadtrip Nation Web pages accessible to all, here are a few plugins for the Chrome browser to help you.

c122jan2714.notebook January 27, 2014

Google Docs: Access, create, edit, and print

AGENCY EXPRESS 3.0. A Guide to Online Ordering

Report Commander 2 User Guide

Service Line Export and Pivot Table Report (Windows Excel 2010)

Google Docs Tipsheet. ABEL Summer Institute 2009

with TestComplete 12 Desktop, Web, and Mobile Testing Tutorials

Hands-on Lab Session 9909 Introduction to Application Performance Management: Monitoring. Timothy Burris, Cloud Adoption & Technical Enablement

The PCC CIS etutorial to Windows

ATMS ACTION TRACKING MANAGEMENT SYSTEM. Quick Start Guide. The ATMS dev team

CTG Basic Troubleshooting

Editing Webpages in N/Vu

Browser Configuration Reference

Agent and Agent Browser. Updated Friday, January 26, Autotask Corporation

To create, upload, share, or view shared files through Google Apps, go to Documents in the black bar above.

NVU Web Authoring System

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

Title and Modify Page Properties

ClassLink Launchpad FAQ

Qualys Browser Recorder User Guide Version April 6, 2018

Browsing the World Wide Web with Firefox

Guide to fix the problem with Problets

Student Success Guide

AUTOMATION ANYWHERE ENTERPRISE 11 LTS

Using Handbrake to Reformat DVD Clips

Shopping Cart: Queries, Personalizations, Filters, and Settings

Blogging at

USER GUIDE: EDITOR. Drag & drop system: Content Manager Style Editor Add Elements Undo/Redo Save...

ANIMATOR TIMELINE EDITOR FOR UNITY

Tutorial 4. Activities. Code o Editor: Expression Web o Focus : Base Layout, navigation with folders, external stylesheets, Open up Expression Web

Blackboard 9 for Learners

COMP 250 Winter stacks Feb. 2, 2016

Module 1: Information Extraction

leveraging your Microsoft Calendar Browser for SharePoint Administrator Manual

The default template that comes with the blog template does not have a "blog roll" configured. However it is relatively straightforward to create one.

4. Web-based Switch Configuration

Getting Started Guide

Controlled Assessment Task. Question 1 - Describe how this HTML code produces the form displayed in the browser.

Course Folder and Files Instructions for download and use

Instructions for creating and modifying queries will be available in the future.

HOW TO SIGN IN... 3 TRAINING FOR GOOGLE APPS... 4 HOW TO USE GOOGLE DRIVE... 5 HOW TO CREATE A DOCUMENT IN DRIVE... 6

Transcription:

Basic Selenium Scripting Tutorial Using Selenium IDE Firefox Add-On v2.9.0 Author: Andrew Chan

Table of Contents 1 TIPS ON PROBING 2 BASIC SELENIUM SCRIPTING 2.1 Recording the script 2.2 Organizing the script 2.3 Testing the recorded script 3 ADDING FLOW CONTROL TO THE SCRIPTS 3.1 Download the Flow Control Firefox add-on 3.2 Adding Flow Control to the script 4 USING VARIABLES IN YOUR SELENIUM SCRIPT 4.1 FOR loop 4.2 Return variable

1 TIPS ON PROBING When creating Selenium scripts: minimize the number of steps/transactions. make the script as simple as possible. Remember, the idea of probing is to find out if a site works properly. A script should report the problem. It is not meant to be used to diagnose the problem. 2 BASIC SELENIUM SCRIPTING For basic Selenium scripting (probably covering 90% of the probes), follow the instructions below for recording the scenario. For the purpose of this tutorial, we will create a script that opens the Google homepage, searches for Selenium IDE and clicks the Selenium homepage from the results page. 2.1 Recording the script 1) Download and install Selenium IDE Firefox plugin from http://www.seleniumhq.org/download/ (v2.9.0 at time of authoring this tutorial). 2) Select Install now to install all 5 plugins on the next screen. 3) Launch Selenium IDE from Firefox (FF). Clear out the tabs in FF and click on the red record button to make sure that it s recording: 4) In the FF address bar, enter www.google.com. In the search box, enter the term Selenium IDE and press Enter (the result might appear before but we are still going to press enter in this tutorial). 5) You will notice there are some commands already recorded in the Selenium IDE. When you get to the search results page, you want to make sure that the results page contains the Selenium homepage. In FF, highlight the Selenium - Web Browser Automation link and right click. In the right click menu, click verify Text link=selenium - Web Browser

Automation Selenium. 6) That should automatically insert a verifytext command into your script to make sure the link exists on the results page. Please note that verifytext (or asserttext) is the single most important Selenium command as you can essentially use this on every page to make sure the scenario is still on track and probe is still functioning normally. 7) Finish the probing scenario by clicking on the Selenium - Web Browser Automation link (remember, Selinium should still be recording!) 8) Ensure that the script checks that the correct page loads by verifying that the text What is Selenium? exists on the Selenium homepage (same method as step 4): 9) There you have finished recording your probing scenario.

2.2 Organizing the script In order to best use the Selenium script with the Synthetic Playback agent in Performance Management, the script needs to be rearranged in such a way that each test case represent one page. We will continue to use the script created above as an example. 1) Before any rearrangement, stop the recording. The recorded script should contain all commands under one Untitled Test Case. 2) Rename the current Untitled test case and create 2 extra test cases to represent the 3 pages that the probe accesses. 3) By using cut and paste, redistribute the commands to where they each belong. Remember, the verifytext command stays on the same test case page as the command that opens it. At the end you should have these 3 test cases containing these commands.

4) Save each test case (page) into its own html file. Ideally use the test case name as the html file name. 5) Last but not least, save this probing scenario as one test suite. For ease of loading into the Synthetic Script Manager afterwards, please give the test suite a.testsuite

extension. 2.3 Testing the recorded script Now that you have rearranged and saved the test case pages, it is time to test your script by running it in Selenium IDE. 1)

2) Verify the results by going to the logs tab. You may find the following error: The reason that you see the failure is with Google, when you press on the search button, it doesn t go to a new page and Selenium s click command does not know that. To resolve this, you will need to add a manual pause command before the verifytext. Make sure you add the time required to pause in the target field, as shown in the next graphic. 3) Save and rerun the test suite. It should pass this time. 3 ADDING FLOW CONTROL TO THE SCRIPTS There might be times where you want to have more control over the flow of the script. For example, when a shopping probe logs in to a site and start shopping, it might expect the cart to be empty and there might be some dependencies on that for the script to work. In this scenario, you need to add the following logic to your script: if cart is empty go to continue else empty the cart continue With the flow control package, you can now do just that!

3.1 Download the Flow Control Firefox add-on Go to this link and install the Selenium Flow Control add-on: https://addons.mozilla.org/enus/firefox/addon/flow-control/ After this add-on is installed, the following commands are added: gotoif, gotolabel, while, label These commands provide flow control in your selenium scripting. 3.2 Adding Flow Control to the script Now let s take a look at how we can implement something as simple as the check for empty shop cart mentioned in the beginning of section 3: 1) gotoif here checks if the variable ${total} is 0 in the cart. If it is, then skip over commands and go directly to where it is labelled nothingincart 2) This tells the script to come to this line when (labelled nothingincart ) the cart is empty 4 USING VARIABLES IN YOUR SELENIUM SCRIPT You can also use variables in Selenium IDE. Here are two examples where variables are used in Selenium scripts.

4.1 FOR loop With a variable acting as a counter and gotoif, you can create a for loop as shown below: 1) create a variable named counter with the store command: 2) then by using together with the gotoif/label commands from the flow control add-on. You have a for loop: Note that this loop starts from label again and loops around until the counter variable reaches 10. Then it breaks to go to the label very_end. 4.2 Return variable Some commands also return true or false. With Selenium IDE, you can store the returned value into a variable to be used later: 1) This script checks if an element exists or not (in this case, the 18 th row in a table on the page). The script then stores whether the value is true or false in the variable isdone.

2) The variable isdone is then checked before going to another section of the script (i.e. labelled Done)