54
SIKULI USING SCREENSHOTS FOR GUI AUTOMATION AND TESTING Tsung-Hsiang (Sean) Chang, Rob Miller MIT CSAIL Collaborator: Tom Yeh 1 1 2010年6月11日星期五

Sikuli: Using Screenshots for GUI Automation and Testing

  • Upload
    vgod

  • View
    13.228

  • Download
    5

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Sikuli: Using Screenshots for GUI Automation and Testing

SIKULIUSING SCREENSHOTS FOR GUI AUTOMATION AND TESTING

Tsung-Hsiang (Sean) Chang, Rob MillerMIT CSAIL

Collaborator: Tom Yeh

1

12010年6月11日星期五

Page 2: Sikuli: Using Screenshots for GUI Automation and Testing

How to tell computers what to do?

2

22010年6月11日星期五

Page 3: Sikuli: Using Screenshots for GUI Automation and Testing

SHELL SCRIPT

case $rtval in 1) rm -f /tmp/dirip.$$ ; return ;; 255) rm -f /tmp/dirip.$$ ; return ;; esac mfile=`cat /tmp/dirip.$$` if [ -z $mfile ] then mfile=`pwd`/* else grep "*" /tmp/dirip.$$ if [ $? -eq 1 ] then! mfile=$mfile/* fi fi for i in $mfile do if [ -f $i ] then! echo "$i Delete?" >> /tmp/finallist.$$ fi! done

3

32010年6月11日星期五

Page 4: Sikuli: Using Screenshots for GUI Automation and Testing

4

42010年6月11日星期五

Page 5: Sikuli: Using Screenshots for GUI Automation and Testing

GUI AUTOMATION

5

52010年6月11日星期五

Page 6: Sikuli: Using Screenshots for GUI Automation and Testing

1

2

3

6

62010年6月11日星期五

Page 7: Sikuli: Using Screenshots for GUI Automation and Testing

7

72010年6月11日星期五

Page 8: Sikuli: Using Screenshots for GUI Automation and Testing

click click

7

72010年6月11日星期五

Page 9: Sikuli: Using Screenshots for GUI Automation and Testing

SIKULI SCRIPT8

82010年6月11日星期五

Page 10: Sikuli: Using Screenshots for GUI Automation and Testing

SIKULI TEST9

92010年6月11日星期五

Page 11: Sikuli: Using Screenshots for GUI Automation and Testing

OUTLINE

• Problem - How to refer to a GUI widget?

• Sikuli Script - examples and demos

• Sikuli Test - demo

• Test By Demonstration

• Support of testing practices

• Conclusions

10

102010年6月11日星期五

Page 12: Sikuli: Using Screenshots for GUI Automation and Testing

HOW TO REFER TO A GUI WIDGET?

11

112010年6月11日星期五

Page 13: Sikuli: Using Screenshots for GUI Automation and Testing

HOW TO REFER TO A GUI WIDGET?

<AWTTestScript> <launch classpath="src/demo" args="[]" class="CelsiusConverter" method="main" /> <action args="45" method="actionKeyString"/> <action class="javax.swing.AbstractButton" args="Convert..." method="actionClick"/> <assert value="113 Fahrenheit" component="113 Fahrenheit" method="getText"/> <terminate/></AWTTestScript>

Abbot

by pre-programmed references

11

112010年6月11日星期五

Page 14: Sikuli: Using Screenshots for GUI Automation and Testing

HOW TO REFER TO A GUI WIDGET?

<AWTTestScript> <launch classpath="src/demo" args="[]" class="CelsiusConverter" method="main" /> <action args="45" method="actionKeyString"/> <action class="javax.swing.AbstractButton" args="Convert..." method="actionClick"/> <assert value="113 Fahrenheit" component="113 Fahrenheit" method="getText"/> <terminate/></AWTTestScript>

Abbot

by pre-programmed references

Autoit

by absolute locations

11

112010年6月11日星期五

Page 15: Sikuli: Using Screenshots for GUI Automation and Testing

Use Screenshots!

12

122010年6月11日星期五

Page 16: Sikuli: Using Screenshots for GUI Automation and Testing

TEMPLATE MATCHING

click(                            )

13

132010年6月11日星期五

Page 17: Sikuli: Using Screenshots for GUI Automation and Testing

TEMPLATE MATCHING

click(                            )

13

132010年6月11日星期五

Page 18: Sikuli: Using Screenshots for GUI Automation and Testing

1

2

3

EXAMPLE 1:EMPTY TRASH CAN

14

142010年6月11日星期五

Page 19: Sikuli: Using Screenshots for GUI Automation and Testing

EX2: FACEBOOK STALKER

15

152010年6月11日星期五

Page 20: Sikuli: Using Screenshots for GUI Automation and Testing

EX2: FACEBOOK STALKER

15

152010年6月11日星期五

Page 21: Sikuli: Using Screenshots for GUI Automation and Testing

16

162010年6月11日星期五

Page 22: Sikuli: Using Screenshots for GUI Automation and Testing

RESTRICT SEARCH REGION

17

172010年6月11日星期五

Page 23: Sikuli: Using Screenshots for GUI Automation and Testing

EX3: MUTE SPEAKERS

18

182010年6月11日星期五

Page 24: Sikuli: Using Screenshots for GUI Automation and Testing

EX3: MUTE SPEAKERS

18

182010年6月11日星期五

Page 25: Sikuli: Using Screenshots for GUI Automation and Testing

SPATIAL OPERATORS

19

192010年6月11日星期五

Page 26: Sikuli: Using Screenshots for GUI Automation and Testing

SPATIAL OPERATORS

19

192010年6月11日星期五

Page 27: Sikuli: Using Screenshots for GUI Automation and Testing

SPATIAL OPERATORS (2)

20

202010年6月11日星期五

Page 28: Sikuli: Using Screenshots for GUI Automation and Testing

EX4: SET IP ADDRESS

21

212010年6月11日星期五

Page 29: Sikuli: Using Screenshots for GUI Automation and Testing

VISUAL-EVENT-DRIVEN PROGRAMMING

22

222010年6月11日星期五

Page 30: Sikuli: Using Screenshots for GUI Automation and Testing

VISUAL-EVENT-DRIVEN PROGRAMMING

22

222010年6月11日星期五

Page 31: Sikuli: Using Screenshots for GUI Automation and Testing

SIKULI TEST

23

232010年6月11日星期五

Page 32: Sikuli: Using Screenshots for GUI Automation and Testing

VISUAL ASSERTION

• Verify appearance

24

242010年6月11日星期五

Page 33: Sikuli: Using Screenshots for GUI Automation and Testing

VISUAL ASSERTION

• Verify replacement

25

252010年6月11日星期五

Page 34: Sikuli: Using Screenshots for GUI Automation and Testing

TEST BY DEMONSTRATION

click

detect changes

26

262010年6月11日星期五

Page 35: Sikuli: Using Screenshots for GUI Automation and Testing

Demo

27

272010年6月11日星期五

Page 36: Sikuli: Using Screenshots for GUI Automation and Testing

GENERATE ACTION COMMANDS

mouse down

mouse up

‘A’down

‘A’up

‘b’down

‘b’up

28

282010年6月11日星期五

Page 37: Sikuli: Using Screenshots for GUI Automation and Testing

GENERATE ACTION COMMANDS

low-level events

mouse down

mouse up

‘A’down

‘A’up

‘b’down

‘b’up

28

282010年6月11日星期五

Page 38: Sikuli: Using Screenshots for GUI Automation and Testing

GENERATE ACTION COMMANDS

low-level events

high-level commands

click type “Ab”

mouse down

mouse up

‘A’down

‘A’up

‘b’down

‘b’up

28

282010年6月11日星期五

Page 39: Sikuli: Using Screenshots for GUI Automation and Testing

GENERATE ACTION COMMANDS

low-level events

high-level commands

click type “Ab”

mouse down

mouse up

‘A’down

‘A’up

‘b’down

‘b’up

combine with screenshots

click

28

282010年6月11日星期五

Page 40: Sikuli: Using Screenshots for GUI Automation and Testing

GENERATE ASSERTIONS

click

29

292010年6月11日星期五

Page 41: Sikuli: Using Screenshots for GUI Automation and Testing

GENERATE ASSERTIONS

click

1. find differences / manually hint

29

292010年6月11日星期五

Page 42: Sikuli: Using Screenshots for GUI Automation and Testing

GENERATE ASSERTIONS

2. group together

click

1. find differences / manually hint

29

292010年6月11日星期五

Page 43: Sikuli: Using Screenshots for GUI Automation and Testing

GENERATE ASSERTIONS

2. group together3. combine with assertExist

click

1. find differences / manually hint

29

292010年6月11日星期五

Page 44: Sikuli: Using Screenshots for GUI Automation and Testing

GENERATE ASSERTIONS

2. group together3. combine with assertExist

click

1. find differences / manually hint

29

292010年6月11日星期五

Page 45: Sikuli: Using Screenshots for GUI Automation and Testing

jUNIT INTEGRATION

30

302010年6月11日星期五

Page 46: Sikuli: Using Screenshots for GUI Automation and Testing

TEST-DRIVEN DEVELOPMENT

31

312010年6月11日星期五

Page 47: Sikuli: Using Screenshots for GUI Automation and Testing

READABILITY OF CODE

32

322010年6月11日星期五

Page 48: Sikuli: Using Screenshots for GUI Automation and Testing

PLATFORM INDEPENDENCE

• Works on ANY GUI that can be displayed on Windows/Linux/Mac

• Virtual machines

• Remote desktop

• Mobile simulators: Android, iPhone

• Web: Flash, HTML+Javascript

33

332010年6月11日星期五

Page 49: Sikuli: Using Screenshots for GUI Automation and Testing

34

342010年6月11日星期五

Page 50: Sikuli: Using Screenshots for GUI Automation and Testing

34

342010年6月11日星期五

Page 51: Sikuli: Using Screenshots for GUI Automation and Testing

LIMITATIONSTheme Variations

Visibility Constraints

35

352010年6月11日星期五

Page 52: Sikuli: Using Screenshots for GUI Automation and Testing

DISCUSSIONSikuli programs are written against the user interface instead of an API

UI: visible, familiar, always exists API: faster, probably more stable

36

362010年6月11日星期五

Page 53: Sikuli: Using Screenshots for GUI Automation and Testing

FUTURE WORK

• fast and accurate OCR on screen

• more robust against different skins

37

372010年6月11日星期五

Page 54: Sikuli: Using Screenshots for GUI Automation and Testing

Thanks!

http://sikuli.csail.mit.edu

New Sikuli 0.10 released.

Follow us on twitter @sikuli

Thanks to our funding sources: NSF and Quanta Computer (as a part of TParty project.)

or, just google “sikuli”

38

382010年6月11日星期五