Welcome to the TestModeller.io selenium tutorial for the Java programming language !
In this tutorial we'll be covering how to get started with TestModeller.io for selenium using a Java automation framework.
This is aimed for first-time users along with users who have an existing java selenium automation framework.
A demonstration of Test Modeller for Selenium Java Automation Frameworks covered in this tutorial.
TestModeller.io is a browser-based solution that enables users to:
This quick start guide provides an overview for new users to get started with creating automation for a Java Selenium based automation framework to quickly start creating models and associated automation.
For Java Selenium this means creating models which automatically generate Selenium code in Java which can be directly plugged into your framework seamlessly
This section is by no means comprehensive and intended as a quick start guide. If you wish to learn more about modelling we recommend you review our knowledge base along with our video tutorials for a comprehensive guide to creating models and test automation.
The goal is to equip the reader with the working knowledge needed to get started with creating java test automation to test their own systems and integrate into their own automation frameworks. With TestModeller.io, this means automatically generating complete automated test suites from models that are quick to build and easy to maintain.
Here we'll be installing all the prerequisites you need to get started with Selenium test automation in Java.
Make sure to restart the Terminal or Command line prompt to load the new environment variables.
In this tutorial we will be executing our tests on Google Chrome. You can use Firefox driver and Internet Explorer driver available from the Selenium website if you wish to interchange chrome for either of these browsers and beyond.
All code created using TestModeller.io uses code templates which define the structure and type of code to be created. Test Modeller provides support for numerous open source frameworks out-the-box made available on the Curiosity Software GitHub page.
The sample framework provides pre-configured code templates within the ‘Code Template’ directory. To import these into Test Modeller follow these steps or watch the video below.
Create a new project within Test Modeller which will be used as a workspace for our page objects and models created for consumption by the automation framework.
Note: This is using the sample framework and configuration provided by Test Modeller. You may have your own automation framework which you wish to utilise. This can be integrated into Test Modeller by configuring your own code templates. A video tutorial is available here.
The TestModeller.io scanner is an accelerator for scanning existing web applications to quickly assemble and create page objects which can be consumed directly in your automation Framework.
It is useful to check your automation framework is up to date and compiling correctly. Within the automation framework directory you can perform a compilation at any time using the mvn clean package command
Start creating an automation model of the system under test.
Generate associated Java automation code for your model.
Test cases are equivalent to paths through the model of a system under test. They are generated automatically from a model, with or without test data and test automation associated with them. Coverage techniques are also available to generate the smallest set of test cases needed to test given features with a required level of rigour.
The tests generated by TestModeller.io are the optimal set of tests to maximise coverage across the model. You can learn more about test coverage and how to edit coverage settings within TestModeller.io at our knowledge base here.
Once you have created a model with overlaid automation, and a test suite containing associated paths, you are ready to create automation scripts for the framework being consumed, in this case Java using Selenium.
Take the automation scripts generated by TestModeller.io and integrate them into your automation framework for execution.
You can run the tests within the IntelliJ IDE by right clicking on the test case and selecting to run it. Here we will run the entire test suite through the command line.
The example automation framework uses TestNG as the test execution runner and results engine. You can tag tests, and also specify exactly which tests to run within TestNG either on your local machine or within your CI execution environment. We reccomend referring to the TestNG documentation here to learn more about configuring TestNG for your requirements.
Import existing or custom coded page objects into TestModeller.io to utilise them for creating automated models.
The page object importer is a vital component for test automation with TestModeller. This is useful for two reasons. Firstly, it may be the case that you have an existing automation framework with page objects already defined. Secondly there may be instances where you need to embed some custom code into TestModeller.io to perform specific actions which are not directly available within TestModeller. TestModeller.io supports full synchronisation with page objects from code, that means you can keep editing code and resynchronising into TestModeler at any time. If your changes effects any your models we notify you of the impacted models which need updating.
TestModeller.io features a full syncronisation engine for page objects. TestModeller.io will first attempted to do this using a GUID if one is defined in the class. You'll notice for page objects generated from TestModeller.io it does this by embedding the @TestModellerModuleId annotation at the top of the class with an associated GUID already defined. If there is no matching class for the GUID it will search for an object with the same path and name within the project. Otherwise a new module is created and no synchronisation occurs.
If you have your own automation framework it will be architectured in a particular way with specific naming conventions and coding standards. Everything in TestModeller.io previously created was done so using code templates which define the structure and type of code to be created. In this section, we'll review the associated templates and where to edit them.
The example java framework has been built for Java 8. This error is caused because of the use of Java 9 instead of Java 8. The easiest solution would be to switch to Java 8 JRE. It is also possible to upgrade the Framework to work with Java 9.