Sikuli: Using Screenshots for GUI Automation and Testing

Preview:

DESCRIPTION

 

Citation preview

SIKULIUSING SCREENSHOTS FOR GUI AUTOMATION AND TESTING

Tsung-Hsiang (Sean) Chang, Rob MillerMIT CSAIL

Collaborator: Tom Yeh

1

12010年6月11日星期五

How to tell computers what to do?

2

22010年6月11日星期五

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日星期五

4

42010年6月11日星期五

GUI AUTOMATION

5

52010年6月11日星期五

1

2

3

6

62010年6月11日星期五

7

72010年6月11日星期五

click click

7

72010年6月11日星期五

SIKULI SCRIPT8

82010年6月11日星期五

SIKULI TEST9

92010年6月11日星期五

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日星期五

HOW TO REFER TO A GUI WIDGET?

11

112010年6月11日星期五

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日星期五

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日星期五

Use Screenshots!

12

122010年6月11日星期五

TEMPLATE MATCHING

click(                            )

13

132010年6月11日星期五

TEMPLATE MATCHING

click(                            )

13

132010年6月11日星期五

1

2

3

EXAMPLE 1:EMPTY TRASH CAN

14

142010年6月11日星期五

EX2: FACEBOOK STALKER

15

152010年6月11日星期五

EX2: FACEBOOK STALKER

15

152010年6月11日星期五

16

162010年6月11日星期五

RESTRICT SEARCH REGION

17

172010年6月11日星期五

EX3: MUTE SPEAKERS

18

182010年6月11日星期五

EX3: MUTE SPEAKERS

18

182010年6月11日星期五

SPATIAL OPERATORS

19

192010年6月11日星期五

SPATIAL OPERATORS

19

192010年6月11日星期五

SPATIAL OPERATORS (2)

20

202010年6月11日星期五

EX4: SET IP ADDRESS

21

212010年6月11日星期五

VISUAL-EVENT-DRIVEN PROGRAMMING

22

222010年6月11日星期五

VISUAL-EVENT-DRIVEN PROGRAMMING

22

222010年6月11日星期五

SIKULI TEST

23

232010年6月11日星期五

VISUAL ASSERTION

• Verify appearance

24

242010年6月11日星期五

VISUAL ASSERTION

• Verify replacement

25

252010年6月11日星期五

TEST BY DEMONSTRATION

click

detect changes

26

262010年6月11日星期五

Demo

27

272010年6月11日星期五

GENERATE ACTION COMMANDS

mouse down

mouse up

‘A’down

‘A’up

‘b’down

‘b’up

28

282010年6月11日星期五

GENERATE ACTION COMMANDS

low-level events

mouse down

mouse up

‘A’down

‘A’up

‘b’down

‘b’up

28

282010年6月11日星期五

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日星期五

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日星期五

GENERATE ASSERTIONS

click

29

292010年6月11日星期五

GENERATE ASSERTIONS

click

1. find differences / manually hint

29

292010年6月11日星期五

GENERATE ASSERTIONS

2. group together

click

1. find differences / manually hint

29

292010年6月11日星期五

GENERATE ASSERTIONS

2. group together3. combine with assertExist

click

1. find differences / manually hint

29

292010年6月11日星期五

GENERATE ASSERTIONS

2. group together3. combine with assertExist

click

1. find differences / manually hint

29

292010年6月11日星期五

jUNIT INTEGRATION

30

302010年6月11日星期五

TEST-DRIVEN DEVELOPMENT

31

312010年6月11日星期五

READABILITY OF CODE

32

322010年6月11日星期五

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日星期五

34

342010年6月11日星期五

34

342010年6月11日星期五

LIMITATIONSTheme Variations

Visibility Constraints

35

352010年6月11日星期五

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日星期五

FUTURE WORK

• fast and accurate OCR on screen

• more robust against different skins

37

372010年6月11日星期五

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日星期五

Recommended