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:
- Experitest Cloud
- Appium
- Quantum Open Source Framework
- TestNG
- Cucumber
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:
- Java 8
- Maven
- IDE (Eclipse/IntelliJ)
- TestNG plugin
- 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:
- Cloud URL
- port
- accessKey
- Device Query (Device where you would like to execute the test)
- Driver Name
- Driver Class associated with the OS
This file structure of Quantum project looks something like this:
F
We will be using the Appium driver to execute our tests. So, we will have to provide the following capabilities in application.properties:
[java]remote.server=
remote.port=443
driver.name=appiumDriver
appium.capabilities.accessKey=
appium.capabilities.deviceQuery=
appium.capabilities.bundleId=com.experitest.ExperiBank
appium.capabilities.driverClass=io.appium.java_client.ios.IOSDriver(Or android if you are running on android device)[/java]
Please comment/remove these following properties in the file, you will not need them.
[java]#perfecto.capabilities.user=<
#generate the security token using this document – #https://developers.perfectomobile.com/display/PD/Security+Token
#perfecto.capabilities.securityToken=<
#perfecto.capabilities.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[/java]
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:
[java]@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[/java]
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.
[java]@QAFTestStep(description=”User is already on Login Page”) public void userAlreadyOnLoginPage() { DriverUtils.getAppiumDriver().findElement(By.xpath(“//*[@id=’usernameTextField’]”)); }[/java]
You can find the XPath with the help of Experitest’s Appium Studio plugin.
In the same way, I write the tests for the other two step definitions. The script looks as follows after adding them.
[java]@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’]”)); }[/java]
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.
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.
Are you ready to scale your enterprise?
Explore
What's New In The World of Digital.ai
100% Test Automation Might Be Desirable, But Is It Practical?
Discover the challenges and value of test automation in achieving 100% coverage for continuous testing. Find the right balance for effective software development.
Digital.ai Continuous Testing, Now Supports Testing on iOS 17 (Beta) Devices
Digital.ai Continuous Testing is the first to support a new operating system version. iOS 17 (Beta) has been released – Discover the new features and see how it works with a demo below.
Ensuring Quality: Digital.ai Continuous Testing Honored with a DevOps Dozen Award
Digital.ai Continuous Testing wins Best Testing Service/Tool at the DevOps Dozen Awards 2022, recognizing their exceptional code quality assurance and innovation.