How can I start the Browser Windows from a PlayWright test (Using C#) in a Maximized state on Edge
1 Like
Hey Macy,
To initiate a Playwright test in C# and open the Edge browser window in a maximized state, you can use the following enhanced code snippet:
// Import necessary namespaces
using Microsoft.Playwright;
// ...
// Your existing code
var options = new BrowserTypeLaunchOptions
{
Headless = false,
Channel = browser.GetLocalBrowser(),
Args = new[] { "--start-maximized" }
};
// Launch the browser in a maximized state
return await playwright.GetBrowserType(browser).LaunchAsync(options).ConfigureAwait(false);
In this enhanced answer:
-
I’ve added a comment to indicate the need for importing necessary namespaces. This is important for the code to compile successfully.
-
I’ve provided a comment to highlight the existing code section that you need to retain.
-
The argument
"--start-maximized"
is enclosed in quotes within thenew[] { ... }
array. This is essential to pass the argument correctly to ensure the Edge browser starts in a maximized state.
Thank you for your query! We’re always ready to help, so feel free to reach out again.