April 22, 2020 Jonny Steiner

Integrate your Quantum Framework Project with Experitest

Introduction

The Quantum open-source framework is one of the newer frameworks developed. It is designed to give QA, developers, and testers everything that they might need from a test framework. The inspiration came from the idea that in today’s world of automated testing for web and mobile apps, it is increasingly difficult to incorporate all of the aspects required to create efficient tests.

Quantum framework was created to enable easy environment setup, test creation, and result analysis.

Integrating and configuring any project’s code base which was already written for something new is always a challenge for every developer. Developers would always prefer to work with the most straightforward way to achieve this. More often than not, it is not the case.

So let’s see how we can configure and integrate your Quantum Framework projects into the SeeTest platform.

All of the code used below can be found in this repository.

Technologies Used in this Guide:

How to integrate SeeTest with Quantum Framework and Appium

As you already know, Quantum is an open-source framework for writing automation scripts.

To get started, we will be using the starter project from Quantum. Quantum frameworkprovides a starter project in GitHub. You can download or clone the project to your local repository. Before that, please make sure you have all these dependencies configured in your IDE:

  1. Java 8
  2. Maven
  3. IDE (Eclipse/IntelliJ)
  4. TestNG plugin
  5. Cucumber Plugin

After you have all of them configured on your IDE, we can get started. Open the Quantum-starter project which you cloned with your IDE. If you have downloaded, extract the zip folder first.

I will be using Eclipse as my IDE to write the tests. You can choose an IDE of your choice. Once you open the project and make sure that all the dependencies are imported, We will start by first configuring the project so as to use the Experitest Cloud.

To You will require the following information:

  1. Cloud URL
  2. port
  3. accessKey
  4. Device Query (Device where you would like to execute the test)
  5. Driver Name
  6. Driver Class associated with the OS

This file structure of Quantum project looks something like this:

Quantum Framework - StarterF

We will be using the Appium driver to execute our tests. So, we will have to provide the following capabilities in application.properties:

remote.server=<experitest_cloud_url>/wd/hub/
remote.port=443
driver.name=appiumDriver
appium.capabilities.accessKey=<your_access_key>
appium.capabilities.deviceQuery=<ios or android>
appium.capabilities.bundleId=com.experitest.ExperiBank
appium.capabilities.driverClass=io.appium.java_client.ios.IOSDriver(Or android if you are running on android device)

Please comment/remove these following properties in the file, you will not need them.

#perfecto.capabilities.user=<<CQ_LAB_USER>>
#generate the security token using this document - #https://developers.perfectomobile.com/display/PD/Security+Token
#perfecto.capabilities.securityToken=<<CQ_LAB_SECURITY_TOKEN>>
#perfecto.capabilities.password=<<CQ_LAB_PASSWORD>>

#perfecto.capabilities.automationName=Appium
#perfecto.capabilities.browserName=MobileOS
#perfecto.download.reports=false
#perfecto.download.summaryReports=false
#perfecto.download.video=false
#perfecto.download.attachments=false
#perfecto.report.location= perfectoReports

With this, you have configured your project to run your scripts on Experitest Cloud. Now, let’s create some scenarios and Step Definitions corresponding to those scenarios.

Creating scenarios and Step Definitions

Here, I will be writing my tests on the EriBank demo application.

I will be creating a file EriBankLoginScenario.feature where I will be writing the scenario for login flow of EriBank application. I am using an Appium tag to recognize the scenarios which will be used later to identify and filter to run only these tag scenarios.

The feature file will look like this:

@appium
Feature: EriBank Login Feature

@appium
Scenario: Login Test Flow
    Given User is already on Login Page
    Then User enters username and password
    And  User is on home page

Given User is already on Login Page

In my First given step, I will be verifying whether I am on the login page so as to confirm whether my application has launched successfully on the device.

Then User enters username and password

In my second step, I would be providing credentials username and password to login to the application.

And User is on home page

In my third step, I will be verifying if I have logged in successfully and reached the home page of the application.

You will see an error on these lines. This is okay because you have not written any step definitions for it. So, that is why you have the error. Once you write them, the errors will go away.

Writing the definitions of these steps:

I will create a EriBankLoginTestStepDefs.java class where I will be writing all my step definitions.

So, the first definition is to check if I am on the login page, I can do it by checking if I am able to find the username field on the device’s screen.

To do this first, you need to create a userAlreadyOnLoginPage method where you write your code to execute. you need to give the @QAFTestStep annotation to your method with the description as the step definition. Quantum framework provides a Utility driver class from where you can fetch the Appium driver you have initialized and use it for automation. So, I try to find the element with the help of its XPath.

@QAFTestStep(description="User is already on Login Page")
    public void userAlreadyOnLoginPage() {
   	 DriverUtils.getAppiumDriver().findElement(By.xpath("//*[@id='usernameTextField']"));
    }

You can find the XPath with the help of Experitest’s Appium Studio plugin.

 

Quantum Framework - Appium Studio

In the same way, I write the tests for the other two step definitions. The script looks as follows after adding them.

@QAFTestStep(description="User enters username and password")
    public void userEntersUsername() {
   	 DriverUtils.getAppiumDriver().findElement(By.xpath("xpath=//*[@id='usernameTextField']")).sendKeys("company");
   	 DriverUtils.getAppiumDriver().findElement(By.xpath("xpath=//*[@id='passwordTextField']")).sendKeys("company");
   	 DriverUtils.getAppiumDriver().findElement(By.xpath("xpath=//*[@id='loginButton']")).click();
    }

    @QAFTestStep(description="User is on home page")
    public void userIsOnHomePage() {
   	 DriverUtils.getAppiumDriver().findElement(By.xpath("//*[@id='makePaymentButton']"));
    }

Now after writing our test class, we now need to set the tests which we want to run. We need to add this in the XML file which we will be running to execute our tests.

Quantum Framework - TestNG Appium

You need to add the name of the driver as a parameter as appiumDriver and remove the rest of the parameters as we will not be using in this case. As mentioned earlier, we will only run scenarios with @appium tag which I have included here. After modifying the XML file, it will look as follows:

Now, your test is ready. You can run this file as a TestNG class and this should be running a test on the Experitest Cloud. Ready to try it? Click here to download the sample code we used above.

Guy ArieliCTO