Skip to content

Automation project for the Interlok GUI developed using Cucumber, Selenium, Maven & Java

Notifications You must be signed in to change notification settings

Co-Din/Interlok-GUITestAutomation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Interlok Maven Central

A Salad Of Automation

Outline

This project has been designed and implemented to learn the basics of Cucumber, Gherkin & Selenium in order to test the 'Interlok' GUI. The initial test plan to be followed can be found at this URL: Interlok UI Test Plan Documents which requires appropriate credentials for access. The documents found at this site are authored by HiggyFella.



Tech Stack

This Project was developed on Windows 10 using the Intellij IDE and the following tech;


Setup


  • Setup a compatible version of a Java 8 Open JDK

    Begin by opening your command terminal and entering the command java -version
    This should either return that you have no version of Java installed or any version that you have installed.
    If this has returned a version which is not Java 8 and you are running Windows I highly recommend removing the other version and starting with a fresh installation the same goes for any Oracle copies of Java 8.
    Follow the steps provided install install Zulu the Azul Open JDK.

    • Windows

      Following the download of your JDK you'll need to supply windows a JAVA_HOME and a JAVA_PATH
      To do so open your file browser and navigate to: Control Panel\System and Security\System using the address bar.
      Once there select the 'Advanced system settings' which should open a separate window (System Properties) on the 'Advanced' tab.
      Select the 'Environmental Variables...' button at the bottom right hand of the window. This should open yet another window for your 'Environment Variables' you'll then want to do the following in the 'System Variables' Segment.
      Double click on the Path variable and then select 'new' and enter the location of your Java JDK i.e C:\Java\zulu8.33.0.1-jdk8.0.192-win_x64\bin making sure to include the 'bin' in the location and then dismiss the window by hitting the 'OK' button.
      Then click on the New... button in the 'System Variables' segment and in the 'Variable Name' input JAVA_HOME and the JDKs location as the 'Variable Value'(this time without 'bin').
      Finally we need to confirm that our installation has worked. Open the command terminal and once again enter the command java -version this should return the Java version you've installed or Java is not recognized as an internal or external command if the latter is the case please scroll to the bottom of this guide and follow the links supplied.

    • Mac

      For Mac OSs start by running the command java -version to see if a Java JDK is already installed if one is you should still install the 'Azul Zulu' JDK and then switch to that JDK version.
      To switch to the 'Zulu JDK' ope you command terminal and run the following /usr/libexec/java_home -V this should show you which Java versions you have installed.
      Then you can select which version of Java you want using:
      export JAVA_HOME='/usr/libexec/java_home -v *Replace with Java Version Here*' this needn't be the exact version it can be a major version.
      Finally confirm which version is running with java -version

    • Linux

      For the Linux start by opening the command terminal and running the command sudo apt update then once this has completed java -version to confirm whether or not there is a version of Java already installed.
      If one has already been installed and is not an open copy of the Java 8 JDK install the following JDK and then switch the version default.
      Run the sudo apt-get install zulu-8 command to install the JDK finally check the version by running the command java -version if it is not the openJDK you can switch using the following:
      sudo update-alternatives --display java shows you which alternatives are available and then sudo update-alternatives --config java which should give you the JDK options to select from.
      Finally confirm that the correct version of Java is being used by running the command java -version.


  • Install one of the following IDEs following the instructions provided on their sites:

    (Both are compatible with Linux, Mac & Windows)

  • Install Maven

    To run this project we also need to install Apache Maven.
    Start by opening your command terminal and running mvn -version this should either return a version which may have been already installed or mvn is not recognized as an internal or external command.
    Download the appropriate format of 'Apache Maven 3.6.0' and then follow the instructions below for installation and config.
    Once downloaded extract the Zip or Tar.gz file to its final destination.

  • Windows

    After finishing the extraction open your file browser and navigate to: Control Panel\System and Security\System using the address bar.
    Once there select the 'Advanced system settings' which should open a separate window (System Properties) on the 'Advanced' tab.
    Select the 'Environmental Variables...' button at the bottom right hand of the window. This should open yet another window for your 'Environment Variables' you'll then want to do the following in the 'System Variables' Segment.
    Double click on the Path variable and then select 'new' and enter the location of your Apache Maven i.e C:\Programs\Apache\Maven\apache-maven-3.6.0\bin making sure to include the 'bin' in the location and then dismiss the window by hitting the 'OK' button.
    Then click on the New... button in the 'System Variables' segment and in the 'Variable Name' input M2_HOME and Maven's location as the 'Variable Value'(this time without 'bin').
    Repeat the above step and create another 'System Variables' this time with the 'Variable Name' M2 and yet again Maven's location as the 'Variable Value' i.e C:\Programs\Apache\Maven\apache-maven-3.6.0.
    Finally check the setup has succeeded by running mvn -version this should now return the 'Maven' version and its location.

  • Mac

    Open the command terminal and navigate to where the files were extracted to and then login as Super – User.
    Run rm Downloads/apache-maven*bin.tar.gz and then ammend the permissions: chown -R root:wheel Downloads/apache-maven*.
    Switch the Maven contents: mv Downloads/apache-maven* /opt/apache-maven and archive the Admin session by running: exit
    Add Maven binaries to the path and append using nano $HOME/.profile and then export PATH=$PATH:/opt/apache-maven/bin then hit Ctrl+x to **Save and Exit from 'nano'*.
    Finally check the setup has been successfully completed by running mvn -version this should now return the 'Maven' version and its location.
    Alternatively you can also install Maven on Mac using the following terminal commands brew update followed by brew install maven.

  • Linux

    You can download the appropriate Maven version using the following commands on terminal: wget https://www-us.apache.org/dist/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz -P /tmp.
    Following this you can extract the file with sudo tar xf /tmp/apache-maven-*.tar.gz -C /opt.

     export M2_HOME=/usr/local/apache-maven/apache-maven-3.6.0
     export M2=$M2_HOME/bin
     export MAVEN_OPTS=-Xms256m -Xmx512m
     export PATH=$M2:$PATH
    

    Finally check the setup has been successfully completed by running mvn -version this should now return the 'Maven' version and its location.
    Alternatively you can also install Maven on Linux system using the following terminal commands sudo apt update followed by apt-cache search maven and then sudo apt install maven.


  • Install Interlok 3.8.3

    To install Interlok 3.8.3 click on the link and follow the guide.
    Begin by downloading the appropriate format of the 'interlok-install-3.8.3-RELEASE' file for your OS and then run the installation.
    Make sure to replace the directory name when prompted to 'Interlok3.8.3' for ease of use.


  • Clone this repo to your local wokspace

    Finally open your command terminal or IDE and navigate to either your workspace or location in which you'd like to setup this project. Then use the following to clone git clone https://github.com/Co-Din/Interlok-GUITestAutomation.git this should clone the whole repo to your local workspace.


  • Final notes on setup:

    • This project has been created with a copy of Chromedriver already supplied and should run out the box.
    • You will however need to create your own EnvVar file in the following location Interlok-GUITestAutomation\src\test\java\com\adaptris\stepdefs\ENVVAR.java and populate the following with the corresponding details:
       public class ENVVAR {
         static String LOGIN_PAGE = "DOMAIN/interlok/login.html";
         static String USERNAME = "USERNAME HERE";
         static String PASSWORD = "PASSWORD HERE";
         static String ADAPTRIS_INSTANCE_PATH = "LOCATION OF YOUR INTERLOK 3.8.3/config";
         static String ADAPTER_DB_PATH = "LOCATION OF YOUR INTERLOK 3.8.3/ui-resources/adapter_gui_db";
         public static File ADAPTER_DB_DIRECTORY = (Paths.get(ADAPTER_DB_PATH).toFile());
         static String ADAPTER_STARTUP = TO BE ADDED;"cmd.exe /c cd \"LOCATION OF INTERLOK 3.8.3" & start cmd.exe /k \"java -cp .;./config;./lib/*; com.adaptris.core.management.SimpleBootstrap\"";
       }
    
    • Commands needed to run Maven:
      • mvn clean : This deletes the target directory which 'cleans' any obsolete class files, java docs, jars, reports and so on
      • mvn install : This installs the packages into the local repository
      • mvn test : This run all the tests

Summary


  • What is Selenium

    Selenium is an open-source testing suite designed to automate the testing of both websites and web applications. It's compatible with a multitude of languages and is compatible with both Windows and Unix systems. It runs through a number of different web-drivers(Chrome, Firefox, Opera and the timeless classic IE) thanks to its Remote Control Server. Selenium has unfortunately not got its own reporting capabilities nor has it got the functionality to run 'Snapshot' or Image testing of it's own accord however these issues are all addressed via the integration of tools such as 'Sikuli', 'Selenium Visual Difference' and 'Fighting Layout Bugs' for the graphical('Snapshot') testing and Jenkins, TestNG, Maven and J-unit for reporting and more accurate tests.

  • What is Cucumber

    According to IBM

    "Cucumber is a BDD framework designed to bridge the gap between business managers and software developers."

    It's main aim is to facilitate the writing of plain language code that is human readable and approachable to someone without a technical background. This is achieved through Cucumber's domain specific language 'Gherkin' and it's simple to understand commands which build 'Features' and 'Scenarios' we'd like to test using steps defined and called upon through the 'Given, When, Then & And' commands.

  • What is Gherkin, is it a translation tool?

    Gherkin is the language used in the '.feature files'. It's only based on a simple set of commands covered in the above section about Cucumber. These commands are useless on their own and require a 'Step Definitions' file known to Cucumber as the 'glue' This file is written in the programming language (in our case Java) and using Cucumber's annotations allows us to develop the translation for simple sentences we'd like to see execute specific scripts:

The below is the step definition written to allow us to search on our active page and confirm there is a blank error bar to begin with.

@And("^sees the error bar is blank$")
public void blank_errorBar() {
  Assert.assertTrue(driver.findElement(By.cssSelector(".alert-box")).isDisplayed());
  Assert.assertEquals("", driver.findElement(By.cssSelector(".alert-box")).getText());
}

This is the techincal side, the non-technical/ human readable side that will be used in the feature file is whatever we place in the first set of brackets after the annotation so the feature file will contain a simple command such as "And sees the error bar is blank".

The final piece of the puzzle is the 'Runner' file this is where Cucumber is run from and options are set so that Cucumber knows where in the project to look for the corresponding files as well as which tests and plugins we would like to use while doing so.
Example:

@RunWith(Cucumber.class)
@CucumberOptions(
       tags = "@FunctionalTests",
       features = "src/test/resources/com/adaptris/features/",
       glue = { "com/adaptris/stepdefs/" },
       plugin = { "json:src/resources/htmlreports/cucumber.json" }
)

  • * Limitations *

    • Neither Cucumber nor Selenium have their own ability to perform snapshot testing
    • Selenium's web-drivers are strictly limited to the manner in which we target a web element and that in itself can prove finnicky. CssSelectors and Xpaths were not always accessible to selenium and manual deletion and creation of the adapters' would change the elements path/location.
    • Support for Firefox's web driver in Selenium is now provided by third-party and flagged numerous bugs while running.
    • Selenium's wait function was not functional and numerous element need time to render before being interacted with, the fallback is Thread.sleep.
    • Cucumber's native reporting was over simplified even though it stored all the data from tests however this was improved by using Trivagos 'Cluecumber' reporting tool.


Related Reading Materials


Java JDK

Azul Docs
Windows
Unix systems

Maven


Syntactic Cheat Sheets




Project Developers



About

Automation project for the Interlok GUI developed using Cucumber, Selenium, Maven & Java

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published