testcafe

How to use disableNativeAutomation in TestCafe for one test only?


Native Automation Mode doesn't support multiple windows. I have two tests. One of them uses multiple windows.

import { Selector, ClientFunction, t } from 'testcafe';
fixture('two tests')
    .page(process.env.SITE_URL)

    test('test1', async t => {
         // usual test
    })
    test('test1', async t => {
         // test uses multiple windows
    })

How to disable Native Automation in TestCafe for test2 only? Thanks in advance.


Solution

  • You can create two separate test runs - in Native Automation mode and without it. Specify test paths with the glob pattern as follows: Test files. Use the --disable-native-automation option for this purpose.

    Run tests with NA:

    testcafe chrome "tests/**/*" "!tests/multiple-tests/**/*"
    

    Run tests without NA:

    testcafe chrome "tests/multiple-tests/**/*" --disable-native-automation
    

    You can do the same with configuration files or with a Runner object. Also, you can filter tests by metadata.