0.0.10 • Published 4 years ago

testcafe-angular-extension v0.0.10

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

testcafe-angular-extension

This small extension for TestCafe provides a class for implementing a Page Object Model hierarchy as well as an extended selector for retrieving Angular component instances.

Install

npm install testcafe-angular-extension

Usage

Simply import and extend the Page class on you Page Object Models and it will provide you with the methods to select elements within its descendants.

To create page object hierarchies and custom elements either extend the Page class or create your own class which takes a Selector as a constructor and initialize it with the extendedSelector method.

Examples

import { Page } from 'testcafe-angular-extension';

class LoginPage extends Page {
    welcomeMessage = this.selector('h1');
    email = this.extendedSelector(TextInput, '#email');
    password = this.extendedSelector(TextInput, '#password');
}

class TextInput {

    public readonly input: Selector;

    constructor(private _selector: Selector) {
        this.input = this._selector.find('input');
    }

    public async type(text: string) {
        await t.typeText(this.input, text);
    }

    public async replace(text: string) {
        await t.selectText(this.input).typeText(this.input, text);
    }

    public async clear() {
        await t.selectText(this.input).pressKey('delete');
    }

    public async getText() {
        await this.input.value;
    }
}

For Angular applications make sure that the application has been bootstraped before the test begins.

import { awaitAngularLoad } from 'testcafe-angular-extension';

fixture `App Test`.page('http://localhost:4200')
    .beforeEach(async () => {
        await awaitAngularLoad();
    });
	
0.0.10

4 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago