Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

In-Container Selenium Tests

DZone's Guide to

In-Container Selenium Tests

An evaluation of Vaadin's testbench Selenium framework, running on a complete Spring Boot container.

· DevOps Zone ·
Free Resource

Discover how you can reduce your Kubernetes installation from 22 steps to 1.

Currently I'm evaluating Vaadin's Testbench Selenium framework. But the principles should be working with other frameworks too, as long as you find a way to register your http session while running the test. For the setup, I'm running Vaadin with Spring Boot and the Vaadin-Spring add-on. The Selenium Tests are running the complete Spring Boot container.


@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = VaadinApplication.class)
@WebIntegrationTest

In the Main UI class I register the UI instance in a simple List Bean called UIRegsitry:

if (uiRegistry != null) {
    uiRegistry.getRegisteredUIs().add(this);
    addDetachListener(event -> uiRegistry.getRegisteredUIs().remove(this));
}

The Registry is optional and gets injected only when running the Selenium tests:

@Autowired(required = false)
private UIRegistry uiRegistry;

Now "inside" the selenium test we can access all of the Vaadin UI Beans in the UI Scope:

UI uiUnderTest = uiRegistry.getRegisteredUIs().get(0);
uiUnderTest.access(() -> bookView = applicationContext.getBean(BookView.class)).get();

productIdentifiers = bookView.getProduct().getProductIdentifiers();

So now we can enter a value with selenium and directly check if all the bindings are working properly by accessing the involved model instances.

Download the Kubernetes cheatsheet to learn more about easy it is to run Kubernetes on any infrastructure with Mesosphere DC/OS

Topics:
selenium ,vaadin ,spring boot ,devops ,web dev

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}