Giter Club home page Giter Club logo

d365-ui-test's Introduction

D365-UI-Test

npm downloads

What's this?

D365-UI-Test is an UI testing framework for easy and robust UI testing in Dynamics 365 CE and Dynamics 365 Portals. It is powered by TypeScript and Puppeteer. You can write your tests in plain JS or in TypeScript. Various functions for interacting with CRM are implemented and can be used for executing your tests.

What does a test look like?

D365-UI-Test is unopinionated, so we don't enforce a specific testing library. The demo tests use jest, but you could just as well use Mocha or someting completely different.

Jest Test:

describe("Basic operations UCI", () => {
    // Login to CRM once for all tests in this module
    beforeAll(async() => {
        jest.setTimeout(60000);

        // You don't need to do it this way, but I did not want to check in the data by accident
        // The file in this example looks like this: https://org.crm4.dynamics.com,[email protected],password
        const config = fs.readFileSync("C:/temp/settings.txt", {encoding: 'utf-8'});
        const [url, user, password] = config.split(",");

        browser = await xrmTest.launch({
            headless: false,
            args: ['--start-fullscreen'],
            defaultViewport: null
        });

        page = await xrmTest.open(url, { userName: user, password: password });
        
        await xrmTest.openAppById("3cd81e96-2940-e811-a952-000d3ab20edc");
    });

    test("It should set string field", async () => {
        jest.setTimeout(60000);
        
        await xrmTest.openCreateForm("account");
        await xrmTest.setAttributeValue("name", "Test name");

        const value = await xrmTest.getAttributeValue("name");
        expect(value).toBe("Test name");

        await xrmTest.reset();
    });

    afterAll(() => {
        return xrmTest.close();
    });

Getting started

Writing tests

There is already a demo project for writing tests with jest available here: https://github.com/DigitalFlow/D365-UI-Test-Jest-Demo

Just follow the instructions in there for getting started.

Without template project

Install this project using npm to get started: npm install d365-ui-test.

Afterwards you can import it in your code like import { XrmUiTest } from "d365-ui-test";.

Use a testing framework such as Jest or Mocha for creating a test suite and set up a XrmUiTest instance in the startup step for launching a Chrome session. Each of your tests can then be written inside the testing framework just as you're used to.

You might want to create your own settings.txt file as in the example above or just enter your credentials inline. The demo tests reside at spec/xrm-ui-test.spec.ts, the demo project can be found in the previous section. This might give you an idea.

What's the difference to EasyRepro?

EasyRepro focuses on interacting with the form mainly by simulating user inputs. When setting lookups, dealing with localization, renaming of labels and more topics, this seemed not the best option. The CRM provides us with various global JS objects, which allow interacting with the system. D365-UI-Test tries to use these JS objects (such as Xrm.Navigation) as much as possible, as this API is not expected to change unexpectedly, yields fast and stable results and causes no issues with localization.

D365-UI-Test also does not limit itself to Dynamics 365 CE, but also for testing connected Portals.

Current limitations

There's a lot to do currently.

Opening create / update forms already works and you can set text / bool / number / currency / option set values. Retrieving of values is also already possible. In addition to that, you can assert control visibilities and disabled states.

License

MIT licensed, have fun :)

d365-ui-test's People

Contributors

digitalflow avatar bpedziwiatr avatar bpedziwiatr-sii avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.