How To Integrate Devaten With Selenium

Selenium Integration

The Selenium integration allows customers to run their Selenium test automation scripts on real browsers in the Perfecto-secured and enterprise-grade testing cloud.Create your Selenium tests in any supported language and any supported test framework.

Prerequisites :


Overview of Devaten Selenium Integration

Design and develop test cases of your application and the same you passed to Devaten application as usecase.

To start/stop recording your testcase/ usecase call the start/stop recording API before/after the test case/usecase.

In order to get the detailed report of your test case/ usecase call the generate report  API of Devaten.

Complete integration diagram of Devaten with Selenium

Implementation of Devaten Selenium Integration

In the Selenium-TestNG Automation framework:

First, set up the test environment using

public void setup() {
System.setProperty("", "H:\\DevatenData\\Devaten_Automation\\chromedriver\\chromedriver.exe");
System.out.print("Inside setUp....... ");
String browserName = readApplicationProperties("browserForTestRun");

In @BeforeSuite initialize the browser and load your application on which you want to automate.

Prepared the test case of your application:

@Test(priority = 1)
public void home() throws InterruptedException {

In the above code, the TestNG @Test annotation method is used for writing a test case to which assign the test priority and written the simple test case to click the Home_page of my application.

But here I want to analyze the performance of the database after execution of the test case home. So here implemented the start/stop recording functionality of the Devaten application

Before the test case of the application is execute implement Devaten start recording REST API

@Parameters({ "TestName" })
public void callStartRecording(String testName) throws InterruptedException {
Response res = RestAssured.given().header("Authorization", "Bearer " + accessToken).header("applicationIdentifier", readApplicationProperties("applicationIdentifier"))
.get(readApplicationProperties("Supermon_url") + "devaten/data/startRecording?usecaseIdentifier="
+ testName);

In the above code @Parameters({TestName}) is the Name of the test which you can give in your testng.xml file this way

In the above code @Parameters({TestName}) is the Name of the test which you can give in your testng.xml file this way

And pass the method name i.e. test case written namely home

<include name="home" />

In this way implemented the start recording API Devaten

Response res = RestAssured.given().header("Authorization", "Bearer " + accessToken)
.header("applicationIdentifier", readApplicationProperties("applicationIdentifier"))
.get(readApplicationProperties("Devaten_url")+"devaten/data/startRecording?usecaseIdentifier="+ testName);

In the above code, the start recording API of Devaten accepts applicationIdentifier which passes through the properties file by declaring in that, and the second parameter is usecaseIdentifier=”testName” declared in testNG.xml file.

After start recording implemented the stop recording using 

@Parameters({ "TestName" })
public void callStopRecording(String testName) throws InterruptedException {
Response res = RestAssured.given().header("Authorization", "Bearer " + accessToken)
.header("applicationIdentifier", readApplicationProperties("applicationIdentifier"))
.get(readApplicationProperties("Devaten_url") + "devaten/data/stopRecording?usecaseIdentifier="
+ testName + "&inputSource=batFile");
// System.out.println(res.getStatusCode());

Here Passed the same parameter of which pass in the start recording. And use @AfterTest annotation so that it can stop the recording after executing the test

Get a report after executing the use cases using 

public void close() throws InterruptedException {
Response report = RestAssured.given().header("Authorization", "Bearer " + accessToken)
.header("applicationIdentifier", readApplicationProperties("applicationIdentifier"))
.get(readApplicationProperties("Supermon_url") + "devaten/data/generateReport");
try (FileWriter file = new FileWriter("report/response.json")) {
// File Writer creates a file in write mode at the given location
// write function is use to write in file,
// here we write the Json object in the file
} catch (IOException e) {
// waitForUserInterfaceToLoad(Constant.DEFAULT_WAIT_TIME);

For getting a report used the Devaten generate report API which is implemented in the @AfterSuite annotation method. The report is stored in the response.json file.

You can view these executed use cases on your Devaten dashboard.  

Established in 2013 as a software consultancy company, Devaten has worked with finance and healthcare businesses to enhance their software development projects. Taking its offerings to the next level, Devaten built a leading use case-based database application monitoring tool, with a unique approach to performance improvement early during software development. Headquartered in Turku, Finland.

Copyright © 2024 Devaten, All rights reserved.