website logo
⌘K
Welcome to Relicx
How does Relicx work ?
Benefits of Relicx
Getting Started
Sign-up
Instrumenting Your App
Security and Privacy
Application & Environments
Adding Application
Adding a new Test Environment
SDK
getSessionUrlCallback()
identify()
Log()
sessionVars()
sessionLabels()
User Sessions
Session Replay and Detail
Developer Console
Automatic Release Validation
How Does Relicx Release Validation Work?
Benefits of Relicx Release Validation
Running Release Validation
Interpreting the results
Adding Tests
Smart Tests
Interactive Test Authoring
Generating Tests from User Sessions
Editing Tests
Running Tests
Test Run Page
Test Suite
CI/CD Integration
Notifications
Slack
Email
Additional Resources
Importing tests into Relicx
Testing Firewall Protected Apps
Timezones
How-to-Guides
Instrumenting Your App
Convert a session with errors to test
Video Resources
Changelog
Docs powered by
Archbee
Additional Resources

Importing tests into Relicx

5min

Our customers, usually have tests written in Cypress, Selenium and other testing frameworks that they want to import into Relicx for various reasons. Importing these manually authored tests into Relicx from other frameworks is fairly simple and straighforward. In the section below we will show you how these tests can be seemlessly migrated.

We have a test written for the Cypress testing framework that tests the Deposit flow in our sample Digital Bank application.

JS
|
describe('DBank app test', function() {
    it('Successfully logs in and makes a deposit', function() {
        cy.visit('http://prod.dbank.staging-apps.relicx.ai:8080/bank/login')

        // Assert that the login page has loaded by checking visibility of the username input field
        cy.get('#username').should('be.visible')

        // Enter username and password

        cy.get('#username')
            .type('jsmith@demo.io')
            .should('have.value', 'jsmith@demo.io') // Assert that the username has been correctly entered

        cy.get('#password')
            .type('Demo123!')
            .should('have.value', 'Demo123!') // Assert that the password has been correctly entered

        cy.get('#submit')
            .click()

        // Assert that the login was successful by checking the URL of the page
        cy.url().should('eq','http://prod.dbank.staging-apps.relicx.ai:8080/bank/home')

        // Navigate to deposit page
        cy.get('#deposit-menu-item')
            .click()

        // Select the account
        cy.get('#selectedAccount')
            .select('95') // Option value for 'Family Checking'
            .should('have.value', '95') // Assert that the correct account has been selected

        // Input the deposit amount
        cy.get('#amount')
            .type('312')
            .should('have.value', '312') // Assert that the correct deposit amount has been entered

        // Submit the deposit
        cy.get('.btn.btn-primary.btn-sm')
            .click()

        // Assert that the deposit was successful
        cy.url().should('have.string','http://prod.dbank.staging-apps.relicx.ai:8080/bank/account/checking-view')

    })
})


To import this test into Relicx, we need to add couple of lines of code that will automatically import this test into Relicx when it is executed in Cypress.

JS
|
describe('DBank app test', function() {
    it('Successfully logs in and makes a deposit', function() {
        cy.visit('http://prod.dbank.staging-apps.relicx.ai:8080/bank/login')

        // Assert that the login page has loaded by checking visibility of the username input field
        cy.get('#username').should('be.visible')

        //-------------------------------------------------------------------
        // Call relicx api to name this test
        //-------------------------------------------------------------------
        cy.window().then((win) => {
            win.relicxSDK.sessionVars({
                testName: "deposit_test_from_cypress",
            });
        })

        cy.get('#username')
            .type('jsmith@demo.io')
            .should('have.value', 'jsmith@demo.io') // Assert that the username has been correctly entered

        cy.get('#password')
            .type('Demo123!')
            .should('have.value', 'Demo123!') // Assert that the password has been correctly entered

        cy.get('#submit')
            .click()

        // Assert that the login was successful by checking the URL of the page
        cy.url().should('eq','http://prod.dbank.staging-apps.relicx.ai:8080/bank/home')

        // Navigate to deposit page
        cy.get('#deposit-menu-item')
            .click()

        // Select the account
        cy.get('#selectedAccount')
            .select('95') // Option value for 'Family Checking'
            .should('have.value', '95') // Assert that the correct account has been selected

        // Input the deposit amount
        cy.get('#amount')
            .type('312')
            .should('have.value', '312') // Assert that the correct deposit amount has been entered

        // Submit the deposit
        cy.get('.btn.btn-primary.btn-sm')
            .click()

        // Assert that the deposit was successful
        cy.url().should('have.string','http://prod.dbank.staging-apps.relicx.ai:8080/bank/account/checking-view')
        //-------------------------------------------------------------------
        // optional tell relicx to stop recording (relicx times out on its own after inactivity)
        //-------------------------------------------------------------------
        cy.window().then((win) => {
            win.relicx?.getCollector().stop();
        })
    })
})


The two blocks of code that we added are as follows

The first block adds a test name i.e. the name of the test in Relicx.

JS
|
 // Call relicx api to name this test
        cy.window().then((win) => {
            win.relicxSDK.sessionVars({
                testName: "deposit_test_imported_from_cypress",
            });
        })


The second block, an optional steps, stops the recording once the test execution is done

JS
|
cy.window().then((win) => {
            win.relicx?.getCollector().stop();
        })


Once the test is executed n Cypress, a corresponding test is automatically created in Relicx.

Document image


Video demo





Updated 23 May 2023
Did this page help you?
PREVIOUS
Additional Resources
NEXT
Testing Firewall Protected Apps
Docs powered by
Archbee
TABLE OF CONTENTS
Video demo
Docs powered by
Archbee