How to use testcafe-browser-tools - 10 common examples

To help you get started, we’ve selected a few testcafe-browser-tools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DevExpress / testcafe / src / browser / provider / index.ts View on Github external
private async _ensureBrowserWindowDescriptor (browserId: string): Promise {
        if (this._getWindowDescriptor(browserId))
            return;

        await this._ensureLocalBrowserInfo(browserId);

        // NOTE: delay to ensure the window finished the opening
        await this.plugin.waitForConnectionReady(browserId);
        await delay(BROWSER_OPENING_DELAY);

        if (this.localBrowsersInfo[browserId])
            this.localBrowsersInfo[browserId].windowDescriptor = await browserTools.findWindow(browserId);
    }
github DevExpress / testcafe / src / browser / provider / built-in / locally-installed.js View on Github external
async openBrowser (browserId, pageUrl, browserName) {
        const args  = browserName.split(' ');
        const alias = args.shift();

        const browserInfo    = await browserTools.getBrowserInfo(alias);
        const openParameters = Object.assign({}, browserInfo);

        if (args.length)
            openParameters.cmd = args.join(' ') + (openParameters.cmd ? ' ' + openParameters.cmd : '');

        await browserTools.open(openParameters, pageUrl);
    },
github reimagined / resolve / examples / todo / testcafe_runner.js View on Github external
#!/usr/bin/env node
const yargs = require('yargs');
const createTestCafe = require('testcafe');
const { getInstallations } = require('testcafe-browser-tools');
const DELAY = 10000;
let testcafe = null;

const argv = yargs
    .option('browser', {
        alias: 'b',
        default: false
    })
    .help().argv;

getInstallations().then(browsers =>
    createTestCafe('localhost', 1337, 1338)
        .then((tc) => {
            testcafe = tc;
            const runner = testcafe.createRunner();
            const browser = argv.browser || Object.keys(browsers).slice(0, 1);
            return runner
                .startApp('npm run start', DELAY)
                .src(['./testcafe/index.tests.js'])
                .browsers(browser)
                .run();
        })
        .then((exitCode) => {
            testcafe.close();
            process.exit(exitCode);
        })
);
github DevExpress / testcafe / src / browser / provider / built-in / locally-installed.js View on Github external
async openBrowser (browserId, pageUrl, browserName) {
        const args  = browserName.split(' ');
        const alias = args.shift();

        const browserInfo    = await browserTools.getBrowserInfo(alias);
        const openParameters = Object.assign({}, browserInfo);

        if (args.length)
            openParameters.cmd = args.join(' ') + (openParameters.cmd ? ' ' + openParameters.cmd : '');

        await browserTools.open(openParameters, pageUrl);
    },
github DevExpress / testcafe / src / browser / provider / built-in / chrome / local-chrome.js View on Github external
export async function start (pageUrl, { browserName, config, cdpPort, tempProfileDir, inDocker }) {
    const chromeInfo           = await browserTools.getBrowserInfo(config.path || browserName);
    const chromeOpenParameters = Object.assign({}, chromeInfo);

    chromeOpenParameters.cmd = buildChromeArgs({ config, cdpPort, platformArgs: chromeOpenParameters.cmd, tempProfileDir, inDocker });

    await browserStarter.startBrowser(chromeOpenParameters, pageUrl);
}
github DevExpress / testcafe / src / browser / provider / built-in / path.js View on Github external
async _handleString (str) {
        const args = splitQuotedText(str, ' ', '`"\'');
        const path = args.shift();

        const browserInfo = await browserTools.getBrowserInfo(path);

        if (!browserInfo)
            return null;

        const params = Object.assign({}, browserInfo);

        if (args.length)
            params.cmd = args.join(' ') + (params.cmd ? ' ' + params.cmd : '');

        return params;
    },
github DevExpress / testcafe / src / browser / provider / built-in / dedicated / chrome / local-chrome.js View on Github external
export async function start (pageUrl, { browserName, config, cdpPort, tempProfileDir, inDocker }) {
    const chromeInfo           = await browserTools.getBrowserInfo(config.path || browserName);
    const chromeOpenParameters = Object.assign({}, chromeInfo);

    chromeOpenParameters.cmd = buildChromeArgs({ config, cdpPort, platformArgs: chromeOpenParameters.cmd, tempProfileDir, inDocker });

    await browserStarter.startBrowser(chromeOpenParameters, pageUrl);
}
github DevExpress / testcafe / src / browser / provider / built-in / dedicated / firefox / local-firefox.js View on Github external
export async function start (pageUrl, runtimeInfo) {
    const { browserName, config } = runtimeInfo;

    const firefoxInfo           = await browserTools.getBrowserInfo(config.path || browserName);
    const firefoxOpenParameters = Object.assign({}, firefoxInfo);

    if (OS.mac && !config.userProfile)
        correctOpenParametersForMac(firefoxOpenParameters);

    firefoxOpenParameters.cmd = buildFirefoxArgs(config, firefoxOpenParameters.cmd, runtimeInfo, runtimeInfo.newInstance);

    await browserStarter.startBrowser(firefoxOpenParameters, pageUrl);
}
github DevExpress / testcafe / src / browser / provider / built-in / dedicated / base.js View on Github external
async isValidBrowserName (browserName) {
        const config      = await this._getConfig(browserName);
        const browserInfo = await getBrowserInfo(config.path || this._getBrowserName());

        return !!browserInfo;
    },
github DevExpress / testcafe / src / browser / provider / built-in / path.js View on Github external
async _handleJSON (str) {
        let params = null;

        try {
            params = JSON.parse(str);
        }
        catch (e) {
            return null;
        }

        if (!params.path)
            return null;

        const openParameters = await browserTools.getBrowserInfo(params.path);

        if (!openParameters)
            return null;

        if (params.cmd)
            openParameters.cmd = params.cmd;

        return openParameters;
    },