Selenium WebDriver Framework: Creating Executor

This is Part 4 of the Selenium WebDriver Framework Series and in this post, we add the Executor Module to the framework. The Executor takes care of selecting the required test classes for execution and triggering the execution.

selenium-framework-execution-module

Before we begin, I want to bring to your attention that I have made a change in the project structure. In the previous posts, we had a single Maven project where the framework was in src/main and the test scripts were in src/test.

This had a few issues with packaging and other things (but works fine if you run from Eclipse or other IDE), so I decided to separate the framework and test scripts to separate Maven projects with this structure.

 

projecttreestructure

But all the other code remains the same.

So let’s continue with the Executor.

Overview

This module will create a GUI application which takes in configuration information from the user for each execution including the scripts to execute. Upon getting the information, it saves them to relevant property files and triggers the execution.

Lets take a look at the ExecuteScripts class which take care of the execution.

  • The performExecution method creates a TestNG testsuite with the test classes coming from getTestClasses method
  • The getTestClasses reads a Script file which contains the fully qualified names of the classes to execute
SEE ALSO:   Selenium WebDriver Framework: WebDriver Core Module

The aim of our Executor module is to populate the script file with the user selected classes and to provide other configuration information.

Executor UI

executor-ui

This is what we want.

  • The first section is the configuration information like browser, timeout, optional profile path etc.
  • In the second section, the user can browse to the test script folder and the tool will automatically load all the scripts.
  • User can select which scripts to run using Configure. Execute will execute the tests.

Please note that, you need not have to configure every time if the scripts and other details remains the same. You can directly run the RunTest class to execute with previously set configuration. The Executor UI is triggered from RunExecutor class.

The Executor UI is a Java Swing application and was created in Eclipse using WindowBuilder plugin. I’m not going into much detail about how it was created, but you checkout the code here.

See it in action.

executorui

 

With this our framework is done!

How to use the framework

  • Get the framework from github. You can either download the folders directly or use git command
  • Import the project into Eclipse as Maven project

import

  • Start modifying the framework to suite your needs in framework project
  • Or start scripting in test-script project

Points to note which creating Test Scripts

  • Scripts are to be created in test-script project/folder
  • All test scripts should extend AxaTest class which provide the driver initialization and assertions.
  • Tests should be annotated with @Test annotation as in any TestNG project
  • Assertions should be done using the assert methods available in AxaTest.
  • Check this previous post on framework core module to see how to use the Object Repository feature/
SEE ALSO:   8 Selenium IDE Plugins you Should be Aware Of

Everything else is up to you. Enjoy

You may also like...

1 Response

  1. Andrew Cannell says:

    Really good stuff so far, looking forward to the next database part

Leave a Reply

Your email address will not be published. Required fields are marked *