Skip to content Skip to sidebar Skip to footer

Testcafe Request With Cookies

I am trying to find a method in testcafes API similar to Cypress' request. Cypress' request will attach any cookies to the request that already exist in the browser so that http r

Solution 1:

You can modify your cookies using the ClientFunctions mechanism. These cookies will be added to further requests. This approach is safe, since every test in TestCafe starts with clear cookies, so cookies modification will not affect other tests. I prepared an example, please see it:

import { ClientFunction } from'testcafe';

const setCookie = ClientFunction(() => {
    document.cookie = "myCustomCookie=myCustomValue";
});

fixture `fixture`
    .page`http://google.com`;

test(`1`, async t => {
    awaitsetCookie();

    await t.typeText('input[type=text]', 'test');

    await t.debug();
});

Solution 2:

Post a Comment for "Testcafe Request With Cookies"