TestCafe v1.7.0 Release Notes

Release Date: 2019-11-21 // over 4 years ago
  • v1.7.0 (2019-11-21)

    โœจ Enhancements

    ๐Ÿฑ โš™๏ธ Identify the Browser and Platform in Test Code (#481)

    โœ… TestCafe now allows you to obtain information about the current user agent. These data identify the operating system, platform type, browser, engine, etc.

    ๐Ÿ“š Use the t.browser property to access user agent data.

    import { Selector } from 'testcafe'; fixture `My fixture` .page `https://example.com`;test('My test', async t =\> { if (t.browser.name !== 'Chrome') await t.expect(Selector('div').withText('Browser not supported').visible).ok(); });
    

    ๐Ÿ“š The t.browser object exposes the following properties:

    Property Type Description Example
    ๐Ÿ“š alias String The browser alias string specified when tests were launched.
    ๐Ÿ“š name String The browser name.
    ๐Ÿ“š version String The browser version.
    ๐Ÿ“š platform String The platform type.
    ๐Ÿ“š headless Boolean true if the browser runs in headless mode.
    ๐Ÿ“š os Object The name and version of the operating system.
    ๐Ÿ“š engine Object The name and version of the browser engine.
    ๐Ÿ“š userAgent String The user agent string.
    ๐Ÿ“š prettyUserAgent String Formatted string with the browser's and operating system's name and version.

    ๐Ÿ“š The following example shows how to create a beforeEach hook that runs for specific browser engines.

    import { Selector } from 'testcafe'; fixture `My fixture` .page `https://example.com` .beforeEach(async t =\> { if (t.browser.engine.name === 'Blink') return; // ... });
    

    ๐Ÿ“š You can also use t.browser to generate the screenshot path based on the browser name. This prevents screenshots taken with t.takeElementScreenshot in different browsers from being overwritten.

    import { Selector } from 'testcafe'; fixture `My fixture` .page `https://example.com`;test('My test', async t =\> { const loginButton = Selector('div').withText('Login'); await t.takeElementScreenshot(loginButton, `auth/${t.browser.name}/login-button.png`); });
    

    ๐Ÿ“š For more information and examples, see Identify the Browser and Platform.

    ๐Ÿ› Bug Fixes

    • ๐Ÿ›  Fixed an error on pages that submit forms immediately after loading (#4360 by @bill-looby-i)
    • โœ… TestCafe now scrolls to elements located inside Shadow DOM roots (#4222)
    • ๐Ÿ›  Fixed an error that occurred when TypeScripts tests that use Node.js globals were run with TestCafe installed globally (#4437)
    • ๐Ÿ›  Fixed the TypeScript definition for the Selector.withAttribute method's return type (#4448)
    • ๐Ÿ›  Fixed an issue when custom browser providers could not take screenshots (#4477)
    • ๐Ÿ‘Œ Support pages that use advanced ES6 module export (testcafe-hammerhead/#2137)
    • ๐Ÿ›  Fixed compatibility issues with Salesforce Lightning Web Components (testcafe-hammerhead/#2152)