Skip to main content

How to use Scenic View for JavaFX Desktop Applications

How to use Scenic View for JavaFX Desktop Applications

Introduction

Scenic View is a JavaFX application designed for inspecting JavaFx GUIs. It works in a similar way as developer plugins for HTML browsers but for JavaFx apps.

With Scenic View you can visually browse through application scenegraph.

Below is shown how basic JavaFx application is inspected by Scenic View.

Scenic View Screenshot

Download Scenic View

Please find a Windows/MacOs/Linux downloadable installation here :

https://github.com/JonathanGiles/scenic-view/tree/master

Starting Scenic View

To launch the inspector:

cd <installation>/scenicview/bin
./scenicView

Consider an example: let's first start Login Demo JavaFX application

Now start the scenic view - it will automatically find and attach to the started app

Click on tree element will display the element inside inspector

You can vice-versa select it straight in the display and the element will be automatically highlighted in the tree

Creating Element Selectors

Say we want our robot to change the value of username and password and then click Login button.

We'll find the elements and retrieve them by css classes and text we found in details panel of scenic view:

	@FindBy(css = "text-field")
	@Wait(value = 40, waitFunc = Wait.WaitFunc.VISIBLE)
	private JavaElement user;

	@FindBy(css = "password-field")
	@Wait(waitFunc = Wait.WaitFunc.VISIBLE)
	private JavaElement pass;

	@FindBy(css = "button[text='Login']")
	@Wait(waitFunc = Wait.WaitFunc.CLICKABLE)
	private JavaElement loginBtn;

	 // now let's do login
	 public void login() {
		user.sendKeys("bob");
		pass.sendKeys("secret");
		loginBtn.click();
	}