intro of selenium

27
2008-10-31 1 Intro of Selenium

Upload: kai-feng-zhang

Post on 05-Dec-2014

3.986 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Intro Of Selenium

2008-10-31 1

Intro of Selenium

Page 2: Intro Of Selenium

2008-10-31 2

Objective

Introduction to aspects of Selenium Target audience: anyone who has interests

in web-app automation

Page 3: Intro Of Selenium

2008-10-31 3

Dilemmas

UI changes Platforms Browsers Development efforts Maintainance efforts

Page 4: Intro Of Selenium

2008-10-31 4

What is Selenium?

Web-based App testing tool, running directly in browser.

Implemented entirely with browser techs DHTML JavaScript Frames

Works by inspecting DOM

Page 5: Intro Of Selenium

2008-10-31 5

What can do?

Browsers-compatible testing – one script, many browsers

Acceptance testing Regression testing

Page 6: Intro Of Selenium

2008-10-31 6

Behind the scenes

Deploy BrowserBot alongside AUT Use JS and IFrame to embed BrowserBot Engine is tweaked to support wide range of

browsers on different OS

Page 7: Intro Of Selenium

2008-10-31 7

Quick Demo

Access google.com Input keyword “selenium” Verify a link

Page 8: Intro Of Selenium

2008-10-31 8

Script looks

Html table<table cellpadding="1" cellspacing="1" border="1"> <tr> <td>open</td><td>/</td><td></td> </tr> <tr> <td>type</td><td>q</td><td>selenium</td> </tr> <tr> <td>clickAndWait</td><td>btnG</td><td></td> </tr> <tr> <td>verifyTextPresent</td><td>selenium.openqa.org</td><td></td> </tr></table>

Page 9: Intro Of Selenium

2008-10-31 9

Script model

Command Target Value

open /

type q selenium

clickAndWait btnG

verifyTextPresent selenium.openqa.org

Page 10: Intro Of Selenium

2008-10-31 10

Action

open type click select clickAndWait

Page 11: Intro Of Selenium

2008-10-31 11

VP

verifyXXX assertXXX For ajax use:

waitForXXX waitForCondition

Page 12: Intro Of Selenium

2008-10-31 12

Locators

Identify elements via locators: id=id link=name dom=document.select[2] xpath=//input[@name=‘btn’] css=a[href=‘#id2’]

Page 13: Intro Of Selenium

2008-10-31 13

String matching

glob:pattern * ?

regexp:pattern exact:string

Page 14: Intro Of Selenium

2008-10-31 14

Playback

Run Walk Step

Page 15: Intro Of Selenium

2008-10-31 15

Test Suite

Html table<table> <tr> <td>Test Suite</td> </tr> <tr> <td><a target="testFrame" href=“google.html">test G

oogle</a></td> </tr></table>

Page 16: Intro Of Selenium

2008-10-31 16

Components

Core IDE RC Grid

Page 17: Intro Of Selenium

2008-10-31 17

Selenium Core

Basis of Selenium IDE and RC Runs test suites on the same server to

avoid the Same Origin problem Don’t have same flexibility as RC, but tests

and code under test is in the same spot

Page 18: Intro Of Selenium

2008-10-31 18

Selenium IDE

for quick recording of tests, but it somewhat lacks for power

Page 19: Intro Of Selenium

2008-10-31 19

Selenium RC

Different langs binding Gives the ability to drive Selenium from a re

al programming language (Java, Perl, Python, Ruby, and more)

Page 20: Intro Of Selenium

2008-10-31 20

Selenium Grid

extends Selenium RC to distribute your tests across multiple servers, saving you time by running tests in parallel.

Page 21: Intro Of Selenium

2008-10-31 21

Browsers support

Browser IDE RC Core

FF 3 Y Y Y

FF 2 Y Y Y

IE 8b1 N/A ? ?

IE 7 N/A Y Y

Safari 3 N/A Y Y

Safari 2 N/A Y Y

Opera 9 N/A Y Y

Opera 8 N/A Y Y

Others N/A Partial

Page 22: Intro Of Selenium

2008-10-31 22

OS Support

OS IDE RC Core

Windows works on FF 2+ Y Y

OS X works on FF 2+ Y Y

Linux works on FF 2+ Y Y

Solaris works on FF 2+ Y Y

Others works on FF 2+ Y Y

Page 23: Intro Of Selenium

2008-10-31 23

Tips

Data-driven Dynamic pages(php, jsp) Record your script in S-IDE, then use it as a

base for a S-RC script Use Firebug to give you the XPath

Page 24: Intro Of Selenium

2008-10-31 24

Extension

There are a lot of commands - you can even add your own custom commands into the user-extensions.js

Page 25: Intro Of Selenium

2008-10-31 25

Problems encountered

Bug Tweak Not support native dialog

Page 26: Intro Of Selenium

2008-10-31 26

Selenium vs. RFT

Development Deployment Platform/browsers support Maintainance Scope

Use right tool case by case

Page 27: Intro Of Selenium

2008-10-31 27

Where to get?

http://selenium.openqa.org/