Search code examples
testingautomationautomated-testse2e-testingtestcafe

Is there a way to pass a string in the userAgent through testcaferc config file


I am trying to pass a string as a part of userAgent from the testcaferc config file. I cant see it working somehow:

I have the following line of code in my testcaferc.json file:

 "browsers": [
        "Chrome:emulation:userAgent=TEST"
    ]

And in the test file, I have the following test:

test.page(`https://www.whatismybrowser.com/detect/what-is-my-user-agent/`)(`testing the user agent`, async t => {
        await t.debug()
    });

I cant see the userAgent getting set up by doing the above.


Solution

  • It looks like you just have a typo in the browser name. You need to write Chrome in lowercase. Take a look at my config that works as expected:

    {
      "browsers": [
        "chrome:emulation:userAgent=TEST"
      ]
    }