playwrightrunsettingsplaywright-dotnet

ViewportSize in .runsettings?


I'm using NUnit and would like to start the browser in a custom size ViewportSize, I know that it is possible through overriding the ContextOptions() method, however I was wondering if this were to be possible by .runsettings also.

I've tried to add it below by going with the browser options documentation, but to be frank i can't really find a clear list on what is and isn't allowed within the .runsettings in regards to playwright or environment variables for playwright. Could anyone shed more light on this?

Code below is from the playwright documentation page.

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
    <!-- NUnit adapter -->
    <NUnit>
        <NumberOfTestWorkers>24</NumberOfTestWorkers>
    </NUnit>
    <!-- General run configuration -->
    <RunConfiguration>
        <EnvironmentVariables>
            <!-- For debugging selectors, it's recommend 
                 to set the following environment variable -->
            <DEBUG>pw:api</DEBUG>
        </EnvironmentVariables>
    </RunConfiguration>


    <!-- Playwright -->
    <Playwright>
        <BrowserName>chromium</BrowserName>
        <ExpectTimeout>5000</ExpectTimeout>
        <LaunchOptions>
            <Headless>false</Headless>
            <Channel>chrome</Channel>

<!-- I tried it here -->
            <ViewportSize>
                <Width>2048</Width>
                <Height>1080</Height>
            </ViewportSize>

        </LaunchOptions>
    </Playwright>


</RunSettings>

Solution

  • The LaunchOptions section is a BrowserTypeLaunchOptions object which doesn't contain options for ViewportSize.