Skip to content

Conversation

sonic16x
Copy link
Contributor

@sonic16x sonic16x commented Sep 22, 2025

Use this example for test

describe("test saveState and restoreState", () => {
    it("saveStorage", async ({browser}) => {
        // go to mock page
        await browser.url("https://authenticationtest.com/simpleFormAuth/");

        // input login
        const emailInput = await browser.$("#email");
        await emailInput.setValue("[email protected]");

        // input password
        const passwordInput = await browser.$("#password");
        await passwordInput.setValue("pa$$w0rd");

        // click to login
        const logInButton = await browser.$('[type="submit"]');
        await logInButton.click();

        const title = await browser.$("h1");

        // check that now we logged in
        await expect(await title.getText()).toBe("Login Success");

        // save state
        await browser.saveState({
            path: path.join(__dirname, 'dump_login.json'),
        });
    })

    it("restoreState", async ({browser}) => {
        // go to mock page
        await browser.url("https://authenticationtest.com/coverage/?id=1");

        // check that we are not logged in
        const navbarText = await browser.$(".navbar-text");
        expect(await navbarText.getText()).toBe("Please Sign In");

        // restore state from prev test
        await browser.restoreState({
            path: path.join(__dirname, 'dump_login.json'),
        });

        // reload page
        await browser.url("https://authenticationtest.com/coverage/?id=1");

        // check that now we logged in
        const navbarTextLink = await browser.$(".navbar-text a");
        expect(await navbarTextLink.getText()).toBe("Sign Out");
    })
})

@sonic16x sonic16x force-pushed the users/rocketraccoon/TESTPLANE-705.save-state branch from 30ddc7f to 665e4b7 Compare September 22, 2025 21:51
Copy link

pkg-pr-new bot commented Sep 23, 2025

Open in StackBlitz

npm i https://pkg.pr.new/gemini-testing/testplane@1139

commit: c161bc7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant