BrowserConnection Object

A connection to a remote browser.

Use this object to run tests on a remote or a mobile device.

BrowserConnection is created with the testCafe.createBrowserConnection function.

The browserConnection.url property returns a URL the remote browser should visit in order to connect to the TestCafe server instance.

When the remote browser establishes connection, the browserConnection.ready event fires. After that, you can pass the BrowserConnection to runner.browsers and start tests.

Example

const createTestCafe = require('testcafe');
let runner           = null;
let testcafe         = null;

createTestCafe('localhost', 1337, 1338)
    .then(tc => {
        testcafe = tc;
        runner   = testcafe.createRunner();

        return testcafe.createBrowserConnection();
    })
    .then(remoteConnection => {

        // Outputs remoteConnection.url so that it can be visited from the remote browser.
        console.log(remoteConnection.url);

        remoteConnection.once('ready', () => {
            runner
                .src('test.js')
                .browsers(remoteConnection)
                .run()
                .then(failedCount => {
                    console.log(failedCount);
                    testcafe.close();
                 });
        });
    });