53
1

UI test automation techniques by an example of JavaFX UI

  • Upload
    yaevents

  • View
    12.458

  • Download
    4

Embed Size (px)

DESCRIPTION

Test automation is an essential part of a software development process. Being used wisely, it • optimizes testing resources, • increases testing quality, • leads to earlier bug detection, • allows to build continuous development processes. UI Test automation requires tools, experience and human time investment. The session demonstrates a solution used by Java and JavaFX quality team based on experience of testing such products as Swing, NetBeans, JavaFX SDK and JavaFX Authoring tool. The solution is designed to address the key aspects of UI test automation: effectiveness, test base scalability, stability, and maintainability. The core part of the solution is an open source high-level UI test library Jemmy. During the session, Alexandre will be creating JavaFX UI tests from scratch and demonstrating existing test base for real JavaFX products. He will give an overview of JemmyFX API and explain how UI test automation aspects are applied to real test code. The session is intended for Java and JavaFX UI application developers and quality engineers as well as for everyone interested in UI testing techniques and approaches

Citation preview

Page 1: UI test automation techniques by an example of JavaFX UI

1

Page 2: UI test automation techniques by an example of JavaFX UI

<Insert Picture Here>

UI test automation techniques by an example of JavaFX UI.

Alexandre (Shura) IlineJava quality architect

Page 3: UI test automation techniques by an example of JavaFX UI

The following is intended to outline our general product direction. It is intended for information purposes, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions.

The development, release, and timing of any features or functionality described for Oracle's products remains at the sole discretion of Oracle.

Page 4: UI test automation techniques by an example of JavaFX UI

4

The presented technology tested on

JavaFX Authoring Tool

Page 5: UI test automation techniques by an example of JavaFX UI

5

<Insert Picture Here>

Agenda

• UI libraries features

(from testing perspective)• UI Sample• Jemmy tool• Writing tests• Reduce test cost support• Remote testing

Page 6: UI test automation techniques by an example of JavaFX UI

<Insert Picture Here>

UI features

Page 7: UI test automation techniques by an example of JavaFX UI

7

UI libraries features Looking from test side

• Hierarchy• Controls• Transformations• Images• Animation• Event queue

Page 8: UI test automation techniques by an example of JavaFX UI

8

Control hierarchy

http://java.sun.com/javafx/1.3/docs/api/

Stage

Scene

ParentControl

Node

Page 9: UI test automation techniques by an example of JavaFX UI

9

Controls

Button

ToggleButton

RadioButton

CheckBox

Slider

ScrollBar

TextBox

ListView

ComboBox

Custom controls

http://java.sun.com/javafx/1.3/docs/api/

Page 10: UI test automation techniques by an example of JavaFX UI

10

Transformations

http://java.sun.com/javafx/1.3/docs/api/

Affine

Rotate

Scale

Shear

Translate

Page 11: UI test automation techniques by an example of JavaFX UI

11

Images

Page 12: UI test automation techniques by an example of JavaFX UI

12

Animation

http://java.sun.com/javafx/1.3/docs/api/

Timeline

Interpolator

KeyFrame

PathTransition

RotateTransition

ScaleTransition

TranslateTransition

Page 13: UI test automation techniques by an example of JavaFX UI

13

User

UI

Otherthreads

Event queue

Page 14: UI test automation techniques by an example of JavaFX UI

14

Tested UI

A Bézier curve is a parametric curve frequently used in computer graphics and related fields.

Page 15: UI test automation techniques by an example of JavaFX UI

<Insert Picture Here>

Jemmy tool

Page 16: UI test automation techniques by an example of JavaFX UI

16

Find Do Ver i fyPass Pass

Pass

Fai l Fai l Fai l

Fai lure analys is

Find next control

To per form operat ion

Ver i fy that expected

State reached

Perform necessary

act ions

UI test workflow

Page 17: UI test automation techniques by an example of JavaFX UI

17

JemmyCore

JemmySGJemmy v2

AWT & Swing

JemmyRemote

JemmyFXRemoteJemmyFXJemmySWT

JRMCJavaFX Authoring

Tool JavaFX

LCDUINetBeans

JDK

Jemmy and extensions

Jemmy v3

JemmyAWT

Page 18: UI test automation techniques by an example of JavaFX UI

18

Hierarchy Criteria

Text

Scroller

Selectable

Mouse

Keyboard

Interfaces

Lookup

Properties

Images

Factory

Comparator

Interfaces API

JemmyCore

AWTRobot

AWT Robot

Text

Scroller

Selectable

Custom

Coords

Thumb ScrollerPro

per

ties

AP

IIm

ages

AP

I

Inp

ut A

PI

Lo

oku

p A

PI

Page 19: UI test automation techniques by an example of JavaFX UI

19

Scenes,nodes

Hierarchy Criteria

AWT Robot

Text

AWT Robot

Scroller

Selectable

Mouse

KeyboardC

usto

m

Interfaces

Lookup

Co

ord

s

Text

ID

Properties

Images

AWTRobot

Factory

Comparator

FX R

obot

Thumb Scroller

Interfaces API

JemmyFX

FXRobot

Pro

per

ties

AP

IIm

ages

AP

I

Inp

ut A

PI

Op

erators A

PI

Lo

oku

p A

PI

Page 20: UI test automation techniques by an example of JavaFX UI

<Insert Picture Here>

Let's test

Page 21: UI test automation techniques by an example of JavaFX UI

21

One line test

Page 22: UI test automation techniques by an example of JavaFX UI

22

• Type• Property

– text– value– ID– tooltip

• Image• Coordinated• Index (last resort)

• Any criteria which could be written in java code

Lookup principles

Test should be able to find control by ...

Page 23: UI test automation techniques by an example of JavaFX UI

23

Lookup code

Page 24: UI test automation techniques by an example of JavaFX UI

24

More lookup code

Page 25: UI test automation techniques by an example of JavaFX UI

25

Control interfaces

Control type Properties

Node Mouse, Keyboard

Control Focusable

ToggleButton Selectable

Text SelectionText

ScrollBar, Slider Scroll

ListView Scroll, Parent<? extends Object>

Scene, Group Parent<Node>

Page 26: UI test automation techniques by an example of JavaFX UI

26

Control interfaces usage code

Page 27: UI test automation techniques by an example of JavaFX UI

27

JemmyFX Browser

Page 28: UI test automation techniques by an example of JavaFX UI

28

UI test

• Customize ...– Curve attributes– View attributes

• Verify image• Generate code• Verify code• Start animation• Verify animation

Page 29: UI test automation techniques by an example of JavaFX UI

29

Test

Page 30: UI test automation techniques by an example of JavaFX UI

30

Waitings

Every UI action takes time

• Wait for everything– Window appearance– Label change– Image appearance– Property change– File update

• Configurable timeouts

• Exceptions

Page 31: UI test automation techniques by an example of JavaFX UI

31

Waiting code

Page 32: UI test automation techniques by an example of JavaFX UI

32

User

UI

Otherthreads

Event queue

Page 33: UI test automation techniques by an example of JavaFX UI

33

UI

Otherthreads

Event queue with a test

Test

Actions

Verifications

Lookup

Page 34: UI test automation techniques by an example of JavaFX UI

34

Pull data through queue

Page 35: UI test automation techniques by an example of JavaFX UI

35

Properties

Control type Properties

Node ID bounds

Control get$tooltip get$cursor

ToggleButton get$pressed

Text text get$strikethrough get$underline

Slider, ScrollBar vertical minimum maximum value

CheckBox state is.tri.state

TextInputControl selection.anchor position text get$columns get$editable

Page 36: UI test automation techniques by an example of JavaFX UI

36

Properties code

Page 37: UI test automation techniques by an example of JavaFX UI

37

Images

- =

Expected Actual Diff

Page 38: UI test automation techniques by an example of JavaFX UI

38

Images code

Page 39: UI test automation techniques by an example of JavaFX UI

39

Animation code

Page 40: UI test automation techniques by an example of JavaFX UI

40

Verifying generated code

Page 41: UI test automation techniques by an example of JavaFX UI

41

TD + *TS NR

TM * NR NC*EA =

NC*

TM – time needed to run the tests manually

TD – time needed for automated test development

TS – time needed for automated test support

NR – number of test runs

NC – number of tested configurations

Test automation effectiveness

Page 42: UI test automation techniques by an example of JavaFX UI

42

What about record&replay?

• Pretty low TD

– Pretty much the same as TM

… but ...

• High TS

– Generates unmaintainable code– No test code encapsulation

Page 43: UI test automation techniques by an example of JavaFX UI

43

Ideal test

• Lives forever• Written in terms of domain model• All the UI logic is hidden within a library

Page 44: UI test automation techniques by an example of JavaFX UI

<Insert Picture Here>

Remote testing

Page 45: UI test automation techniques by an example of JavaFX UI

45

Hierarchy Criteria

Text

Scroller

Selectable

Mouse

Keyboard

Interfaces

Lookup

By

pro

perties

Properties

Images

Factory

Comparator

JemmyRemote

Desktop Device

Properties

Socket

Hierarchy

Page 46: UI test automation techniques by an example of JavaFX UI

46

JemmyRemote

• Benefits– Low load on tested UI– Ability to run on low-end devices

• Limitations– Two-part code– Lookup is only through properties– Slow

Page 47: UI test automation techniques by an example of JavaFX UI

47

AWTRobot

AW

T R

ob

ot

Hierarchy Criteria

Text

Scroller

Selectable

Mouse

Keyboard

Interfaces

Lookup

By

pro

perties

Properties

Images

Factory

Comparator

JemmyFXRemote

Desktop Device

Properties

SocketFXRobot

Scenes,nodes

Page 48: UI test automation techniques by an example of JavaFX UI

48

JemmyFXRemote sample

Page 49: UI test automation techniques by an example of JavaFX UI

49

http://jemmy.dev.java.net

References

[email protected]

[email protected]

https://jemmy.dev.java.net/AutomationEffectiveness.html

https://jemmy.dev.java.net/RecordingVSCoding.html

[email protected]

Page 50: UI test automation techniques by an example of JavaFX UI

<Insert Picture Here>

UI test automation techniques by an example of JavaFX UI.

Alexandre (Shura) IlineJava quality architect

Page 51: UI test automation techniques by an example of JavaFX UI

51

Backup slides

Page 52: UI test automation techniques by an example of JavaFX UI

52

Operators API

<Control type name>Operator.find(SceneOperator, <lookup data>)

Page 53: UI test automation techniques by an example of JavaFX UI

53

JemmyFXScript