<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: [v1.33]</li>
<li>Operating System: [Windows 10, Ubuntu 18, Gentoo]</li>
<li>Browser: [Electron]</li>
<li>Other info:</li>
</ul>
<h3 dir="auto">Source code</h3>




<p dir="auto"><strong>Config file</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// playwright.config.ts
import type {PlaywrightTestConfig} from &quot;@playwright/test&quot;;
import {devices} from &quot;@playwright/test&quot;;

const config: PlaywrightTestConfig = {
    testDir: &quot;./tests&quot;,
    timeout: 2147483647,
    expect: {
        timeout: 1000 * 60,
    },
    fullyParallel: false,
    forbidOnly: !!process.env.CI,
    retries: process.env.CI ? 2 : 0,
    workers: 1,
    reporter: &quot;dot&quot;,
    use: {
        headless: false,
        actionTimeout: 5000,
        viewport: {width: 1920, height: 1080},
        trace: &quot;off&quot;,
        video: {
            mode: &quot;on&quot;,
            size: {width: 1920, height: 1080},
        },
    },
    projects: [
        {
            name: &quot;Electron&quot;,
            use: {
                ...devices[&quot;Electron&quot;],
            },
        },
    ],
};"><pre class="notranslate"><span class="pl-c">// playwright.config.ts</span>
<span class="pl-k">import</span> <span class="pl-s1">type</span> <span class="pl-kos">{</span><span class="pl-v">PlaywrightTestConfig</span><span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"@playwright/test"</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span><span class="pl-s1">devices</span><span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"@playwright/test"</span><span class="pl-kos">;</span>

<span class="pl-k">const</span> <span class="pl-s1">config</span>: <span class="pl-v">PlaywrightTestConfig</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
    <span class="pl-c1">testDir</span>: <span class="pl-s">"./tests"</span><span class="pl-kos">,</span>
    <span class="pl-c1">timeout</span>: <span class="pl-c1">2147483647</span><span class="pl-kos">,</span>
    <span class="pl-c1">expect</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">timeout</span>: <span class="pl-c1">1000</span> <span class="pl-c1">*</span> <span class="pl-c1">60</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-c1">fullyParallel</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
    <span class="pl-c1">forbidOnly</span>: <span class="pl-c1">!</span><span class="pl-c1">!</span><span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-c1">env</span><span class="pl-kos">.</span><span class="pl-c1">CI</span><span class="pl-kos">,</span>
    <span class="pl-c1">retries</span>: <span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-c1">env</span><span class="pl-kos">.</span><span class="pl-c1">CI</span> ? <span class="pl-c1">2</span> : <span class="pl-c1">0</span><span class="pl-kos">,</span>
    <span class="pl-c1">workers</span>: <span class="pl-c1">1</span><span class="pl-kos">,</span>
    <span class="pl-c1">reporter</span>: <span class="pl-s">"dot"</span><span class="pl-kos">,</span>
    <span class="pl-c1">use</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">headless</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
        <span class="pl-c1">actionTimeout</span>: <span class="pl-c1">5000</span><span class="pl-kos">,</span>
        <span class="pl-c1">viewport</span>: <span class="pl-kos">{</span><span class="pl-c1">width</span>: <span class="pl-c1">1920</span><span class="pl-kos">,</span> <span class="pl-c1">height</span>: <span class="pl-c1">1080</span><span class="pl-kos">}</span><span class="pl-kos">,</span>
        <span class="pl-c1">trace</span>: <span class="pl-s">"off"</span><span class="pl-kos">,</span>
        <span class="pl-c1">video</span>: <span class="pl-kos">{</span>
            <span class="pl-c1">mode</span>: <span class="pl-s">"on"</span><span class="pl-kos">,</span>
            <span class="pl-c1">size</span>: <span class="pl-kos">{</span><span class="pl-c1">width</span>: <span class="pl-c1">1920</span><span class="pl-kos">,</span> <span class="pl-c1">height</span>: <span class="pl-c1">1080</span><span class="pl-kos">}</span><span class="pl-kos">,</span>
        <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-c1">projects</span>: <span class="pl-kos">[</span>
        <span class="pl-kos">{</span>
            <span class="pl-c1">name</span>: <span class="pl-s">"Electron"</span><span class="pl-kos">,</span>
            <span class="pl-c1">use</span>: <span class="pl-kos">{</span>
                ...<span class="pl-s1">devices</span><span class="pl-kos">[</span><span class="pl-s">"Electron"</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
            <span class="pl-kos">}</span><span class="pl-kos">,</span>
        <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">]</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Test file (self-contained)</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="test.describe(() =&gt; {

    test.beforeAll(async () =&gt; {
        fs.mkdirSync(testSettings.pathLog, {recursive: true});
        fs.mkdirSync(testSettings.pathLog + `/error${getDate()}`, {recursive: true});
        await BaseTest.startLog()
        electronApp = await electron.launch({
            args: testSettings.electronApp,
        });

        const window = await electronApp.firstWindow();

        userIndex = 0;

        const pids = await BaseTest.getPidScada(electronApp)

        setInterval(async function () {
            await BaseTest.writeLog(pids);
        }, testSettings.intervalLog);
    })

    for (let step = 0; step &lt; testSettings.passes; step++) {
        test(`Step ${step}`, async () =&gt; {
            const window = await electronApp.windows()[0];

            if (step === 0 || testSettings.changeUser) {
                await AuthenticationPageObject.AuthenticationInList(
                    window,
                    data.main.login[userIndex],
                    data.main.password
                );
            }

            try {
                await window.waitForSelector(data.frameXPath.left);
            } catch (error) {
                fs.appendFileSync(
                    `${testSettings.pathLog}error${getDate()}.log`,
                    `${getFullDate()} \n
          ${error}\n`
                );
            }

            await TestFunction.TestAD(window, 239, 93);

            await TestFunction.TestEvent(window);

            await TestFunction.TestTREND(window);

            await TestFunction.TestArchive(
                electronApp,
                OutputOption.outputHorizontalTable,
                window
            );

            await TestFunction.TestDD(window, 230, 115);

            await TestFunction.TestEvent(window);

            await TestFunction.TestTREND(window);

            await TestFunction.TestArchive(
                electronApp,
                OutputOption.outputVerticalTable,
                window
            );

            await TestFunction.TestZDV(window, 230, 110);

            await TestFunction.TestEvent(window);

            await TestFunction.TestTREND(window);

            await TestFunction.TestArchive(
                electronApp,
                OutputOption.outputTrends,
                window
            );

            await TestFunction.TestREGI(window, 233, 111);

            await TestFunction.TestEvent(window);

            await TestFunction.TestTREND(window);

            await TestFunction.TestALARM(window, 239, 93);

            await TestFunction.TestEvent(window);

            await TestFunction.TestTREND(window);

            if (testSettings.changeUser) {
                userIndex == 19 ? (userIndex = 0) : userIndex++;

                await window.mouse.click(1557, 40);
            }
        });
    }
});
});"><pre class="notranslate"><span class="pl-s1">test</span><span class="pl-kos">.</span><span class="pl-en">describe</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>

    <span class="pl-s1">test</span><span class="pl-kos">.</span><span class="pl-en">beforeAll</span><span class="pl-kos">(</span><span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-s1">fs</span><span class="pl-kos">.</span><span class="pl-en">mkdirSync</span><span class="pl-kos">(</span><span class="pl-s1">testSettings</span><span class="pl-kos">.</span><span class="pl-c1">pathLog</span><span class="pl-kos">,</span> <span class="pl-kos">{</span><span class="pl-c1">recursive</span>: <span class="pl-c1">true</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-s1">fs</span><span class="pl-kos">.</span><span class="pl-en">mkdirSync</span><span class="pl-kos">(</span><span class="pl-s1">testSettings</span><span class="pl-kos">.</span><span class="pl-c1">pathLog</span> <span class="pl-c1">+</span> <span class="pl-s">`/error<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-en">getDate</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">}</span></span>`</span><span class="pl-kos">,</span> <span class="pl-kos">{</span><span class="pl-c1">recursive</span>: <span class="pl-c1">true</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-k">await</span> <span class="pl-v">BaseTest</span><span class="pl-kos">.</span><span class="pl-en">startLog</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
        <span class="pl-s1">electronApp</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">electron</span><span class="pl-kos">.</span><span class="pl-en">launch</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
            <span class="pl-c1">args</span>: <span class="pl-s1">testSettings</span><span class="pl-kos">.</span><span class="pl-c1">electronApp</span><span class="pl-kos">,</span>
        <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

        <span class="pl-k">const</span> <span class="pl-s1">window</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">electronApp</span><span class="pl-kos">.</span><span class="pl-en">firstWindow</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

        <span class="pl-s1">userIndex</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span>

        <span class="pl-k">const</span> <span class="pl-s1">pids</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-v">BaseTest</span><span class="pl-kos">.</span><span class="pl-en">getPidScada</span><span class="pl-kos">(</span><span class="pl-s1">electronApp</span><span class="pl-kos">)</span>

        <span class="pl-en">setInterval</span><span class="pl-kos">(</span><span class="pl-k">async</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            <span class="pl-k">await</span> <span class="pl-v">BaseTest</span><span class="pl-kos">.</span><span class="pl-en">writeLog</span><span class="pl-kos">(</span><span class="pl-s1">pids</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-s1">testSettings</span><span class="pl-kos">.</span><span class="pl-c1">intervalLog</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span>

    <span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">let</span> <span class="pl-s1">step</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span> <span class="pl-s1">step</span> <span class="pl-c1">&lt;</span> <span class="pl-s1">testSettings</span><span class="pl-kos">.</span><span class="pl-c1">passes</span><span class="pl-kos">;</span> <span class="pl-s1">step</span><span class="pl-c1">++</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s">`Step <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">step</span><span class="pl-kos">}</span></span>`</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
            <span class="pl-k">const</span> <span class="pl-s1">window</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">electronApp</span><span class="pl-kos">.</span><span class="pl-en">windows</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">[</span><span class="pl-c1">0</span><span class="pl-kos">]</span><span class="pl-kos">;</span>

            <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">step</span> <span class="pl-c1">===</span> <span class="pl-c1">0</span> <span class="pl-c1">||</span> <span class="pl-s1">testSettings</span><span class="pl-kos">.</span><span class="pl-c1">changeUser</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
                <span class="pl-k">await</span> <span class="pl-v">AuthenticationPageObject</span><span class="pl-kos">.</span><span class="pl-en">AuthenticationInList</span><span class="pl-kos">(</span>
                    <span class="pl-s1">window</span><span class="pl-kos">,</span>
                    <span class="pl-s1">data</span><span class="pl-kos">.</span><span class="pl-c1">main</span><span class="pl-kos">.</span><span class="pl-c1">login</span><span class="pl-kos">[</span><span class="pl-s1">userIndex</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
                    <span class="pl-s1">data</span><span class="pl-kos">.</span><span class="pl-c1">main</span><span class="pl-kos">.</span><span class="pl-c1">password</span>
                <span class="pl-kos">)</span><span class="pl-kos">;</span>
            <span class="pl-kos">}</span>

            <span class="pl-k">try</span> <span class="pl-kos">{</span>
                <span class="pl-k">await</span> <span class="pl-s1">window</span><span class="pl-kos">.</span><span class="pl-en">waitForSelector</span><span class="pl-kos">(</span><span class="pl-s1">data</span><span class="pl-kos">.</span><span class="pl-c1">frameXPath</span><span class="pl-kos">.</span><span class="pl-c1">left</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
            <span class="pl-kos">}</span> <span class="pl-k">catch</span> <span class="pl-kos">(</span><span class="pl-s1">error</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
                <span class="pl-s1">fs</span><span class="pl-kos">.</span><span class="pl-en">appendFileSync</span><span class="pl-kos">(</span>
                    <span class="pl-s">`<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">testSettings</span><span class="pl-kos">.</span><span class="pl-c1">pathLog</span><span class="pl-kos">}</span></span>error<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-en">getDate</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">}</span></span>.log`</span><span class="pl-kos">,</span>
                    <span class="pl-s">`<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-en">getFullDate</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">}</span></span> \n</span>
<span class="pl-s">          <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">error</span><span class="pl-kos">}</span></span>\n`</span>
                <span class="pl-kos">)</span><span class="pl-kos">;</span>
            <span class="pl-kos">}</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestAD</span><span class="pl-kos">(</span><span class="pl-s1">window</span><span class="pl-kos">,</span> <span class="pl-c1">239</span><span class="pl-kos">,</span> <span class="pl-c1">93</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestEvent</span><span class="pl-kos">(</span><span class="pl-s1">window</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestTREND</span><span class="pl-kos">(</span><span class="pl-s1">window</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestArchive</span><span class="pl-kos">(</span>
                <span class="pl-s1">electronApp</span><span class="pl-kos">,</span>
                <span class="pl-v">OutputOption</span><span class="pl-kos">.</span><span class="pl-c1">outputHorizontalTable</span><span class="pl-kos">,</span>
                <span class="pl-s1">window</span>
            <span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestDD</span><span class="pl-kos">(</span><span class="pl-s1">window</span><span class="pl-kos">,</span> <span class="pl-c1">230</span><span class="pl-kos">,</span> <span class="pl-c1">115</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestEvent</span><span class="pl-kos">(</span><span class="pl-s1">window</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestTREND</span><span class="pl-kos">(</span><span class="pl-s1">window</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestArchive</span><span class="pl-kos">(</span>
                <span class="pl-s1">electronApp</span><span class="pl-kos">,</span>
                <span class="pl-v">OutputOption</span><span class="pl-kos">.</span><span class="pl-c1">outputVerticalTable</span><span class="pl-kos">,</span>
                <span class="pl-s1">window</span>
            <span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestZDV</span><span class="pl-kos">(</span><span class="pl-s1">window</span><span class="pl-kos">,</span> <span class="pl-c1">230</span><span class="pl-kos">,</span> <span class="pl-c1">110</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestEvent</span><span class="pl-kos">(</span><span class="pl-s1">window</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestTREND</span><span class="pl-kos">(</span><span class="pl-s1">window</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestArchive</span><span class="pl-kos">(</span>
                <span class="pl-s1">electronApp</span><span class="pl-kos">,</span>
                <span class="pl-v">OutputOption</span><span class="pl-kos">.</span><span class="pl-c1">outputTrends</span><span class="pl-kos">,</span>
                <span class="pl-s1">window</span>
            <span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestREGI</span><span class="pl-kos">(</span><span class="pl-s1">window</span><span class="pl-kos">,</span> <span class="pl-c1">233</span><span class="pl-kos">,</span> <span class="pl-c1">111</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestEvent</span><span class="pl-kos">(</span><span class="pl-s1">window</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestTREND</span><span class="pl-kos">(</span><span class="pl-s1">window</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestALARM</span><span class="pl-kos">(</span><span class="pl-s1">window</span><span class="pl-kos">,</span> <span class="pl-c1">239</span><span class="pl-kos">,</span> <span class="pl-c1">93</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestEvent</span><span class="pl-kos">(</span><span class="pl-s1">window</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">await</span> <span class="pl-v">TestFunction</span><span class="pl-kos">.</span><span class="pl-en">TestTREND</span><span class="pl-kos">(</span><span class="pl-s1">window</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">testSettings</span><span class="pl-kos">.</span><span class="pl-c1">changeUser</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
                <span class="pl-s1">userIndex</span> <span class="pl-c1">==</span> <span class="pl-c1">19</span> ? <span class="pl-kos">(</span><span class="pl-s1">userIndex</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">)</span> : <span class="pl-s1">userIndex</span><span class="pl-c1">++</span><span class="pl-kos">;</span>

                <span class="pl-k">await</span> <span class="pl-s1">window</span><span class="pl-kos">.</span><span class="pl-c1">mouse</span><span class="pl-kos">.</span><span class="pl-en">click</span><span class="pl-kos">(</span><span class="pl-c1">1557</span><span class="pl-kos">,</span> <span class="pl-c1">40</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
            <span class="pl-kos">}</span>
        <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Description of the problem</strong></p>
<p dir="auto">I'm testing an Electron application by simulating user interactions and observing how the tested application behaves. These tests can run continuously for weeks or even a month. However, I've encountered an issue where the process.js from the Playwright library starts consuming more and more memory. If it initially consumes 100MB at the start of testing, after a day or two, it can reach 2GB. Could this be a memory leak on your side, or am I doing something incorrectly?</p>
<p dir="auto"><strong>A file with logs of RAM consumption</strong></p>
<p dir="auto"><a href="https://github.com/microsoft/playwright/files/11524413/system.log">system.log</a></p>
<p dir="auto"><strong>Memory consumption graph of one of the test runs</strong></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/55750159/239737848-904e7777-1329-4296-a7d3-ba98c0e56b20.png"><img src="https://user-images.githubusercontent.com/55750159/239737848-904e7777-1329-4296-a7d3-ba98c0e56b20.png" alt="systemTestMemoryInfo" style="max-width: 100%;"></a></p>
<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: [v1.32.1]</li>
<li>Operating System: [Windows 10]</li>
<li>Browser: [ Chromium]</li>
</ul>
<h3 dir="auto">Source code</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I provided exact source code that allows reproducing the issue locally.</li>
</ul>




<p dir="auto"><strong>Link to the GitHub repository with the repro</strong></p>
<p dir="auto"><strong>Config file</strong></p>
<p dir="auto"><strong>Test file (self-contained)</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="sync getText(): Promise&lt;string&gt; {
const context = await chromium.launchPersistentContext('C:\\temp\\playwright-cache', {headless: false, channel: 'chrome' });
const page = context.pages()[0];
await page.goto(&quot;url behind SSO&quot;);
//here user login to the SSO manually for the first time
const text= await page.locator('cssSelector').innerHTML({timeout: 60*1000});
await page.close();
return text
}"><pre class="notranslate"><span class="pl-s1">sync</span> <span class="pl-en">getText</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-v">Promise</span><span class="pl-c1">&lt;</span><span class="pl-s1">string</span><span class="pl-c1">&gt;</span> <span class="pl-kos">{</span>
<span class="pl-s1">const</span> context <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">chromium</span><span class="pl-kos">.</span><span class="pl-en">launchPersistentContext</span><span class="pl-kos">(</span><span class="pl-s">'C:\\temp\\playwright-cache'</span><span class="pl-kos">,</span> <span class="pl-kos">{</span><span class="pl-c1">headless</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span> <span class="pl-c1">channel</span>: <span class="pl-s">'chrome'</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-s1">page</span> <span class="pl-c1">=</span> <span class="pl-s1">context</span><span class="pl-kos">.</span><span class="pl-en">pages</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">[</span><span class="pl-c1">0</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">goto</span><span class="pl-kos">(</span><span class="pl-s">"url behind SSO"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">//here user login to the SSO manually for the first time</span>
<span class="pl-k">const</span> <span class="pl-s1">text</span><span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">locator</span><span class="pl-kos">(</span><span class="pl-s">'cssSelector'</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">innerHTML</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-c1">timeout</span>: <span class="pl-c1">60</span><span class="pl-c1">*</span><span class="pl-c1">1000</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">close</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">return</span> <span class="pl-s1">text</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><strong>Steps</strong></p>
<ol dir="auto">
<li>Playwright opens a browser with persistent context</li>
<li>Playwright navigates to a URL with behind SSO</li>
<li>User enters credentials and logins</li>
<li>Playwright grabs the text and we return it</li>
<li>Function is run for second time</li>
</ol>
<p dir="auto"><strong>Expected</strong><br>
SSO not to be shown as user has already logged in once.</p>
<p dir="auto"><strong>Actual</strong><br>
SSO page is shown every time as session is not saved.</p>
<p dir="auto"><strong>Workaround</strong><br>
If <code class="notranslate">await page.close();</code> is removed, session is correctly saved at the end of the test run and SSO page is no longer shown. However, the browser that was used to get the text required for other tests (that run in an non-persistent browser) remains open through out the test suite running and that is not ideal.</p>