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

Download the blueprint that can take a company of any maturity level all the way up to enterprise-scale continuous delivery using a combination of Automic Release Automation, Automic’s 20+ years of business automation experience, and the proven tools and practices the company is already leveraging.

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 ‘Practical Blueprint to Continuous Delivery’ to learn how Automic Release Automation can help you begin or continue your company’s digital transformation.

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 }}