Closed kabdul-incomm closed 12 months ago
Have you tried running it without passing all these extra arguments?
Yes. And it times out.
Have you tried running it without passing all these extra arguments?
Can you set the $Env:DEBUG="pw:browser,pw:protocol"
env var? this should yield us more output about whats going on.
$Env:DEBUG="pw:browser,pw:protocol
System.AggregateException : One or more errors occurred. (Timeout 180000ms exceeded. =========================== logs ===========================
Could you try running chromium with the default arguments? I see that a few are missing which we are adding.
Could you try running chromium with the default arguments? I see that a few are missing which we are adding. Here is the error response without passing default args. I know this quesiton will pop up. Message: System.AggregateException : One or more errors occurred. (Timeout 180000ms exceeded. =========================== logs ===========================
C:\Users\kabdul\AppData\Local\ms-playwright\chromium-1080\chrome-win\chrome.exe pid=30472 [pid=30472][err] [30472:30700:1110/123241.703:ERROR:policy_logger.cc(154)] :components\enterprise\browser\controller\chrome_browser_cloud_management_controller.cc(163) Cloud management controller initialization aborted as CBCM is not enabled. ============================================================) ----> System.TimeoutException : Timeout 180000ms exceeded. =========================== logs =========================== C:\Users\kabdul\AppData\Local\ms-playwright\chromium-1080\chrome-win\chrome.exe pid=30472 [pid=30472][err] [30472:30700:1110/123241.703:ERROR:policy_logger.cc(154)] :components\enterprise\browser\controller\chrome_browser_cloud_management_controller.cc(163) Cloud management controller initialization aborted as CBCM is not enabled.
did you also remove the IgnoreAllDefaultArgs flag? since now there are no arguments at all.
did you also remove the IgnoreAllDefaultArgs flag? since now there are no arguments at all.
No. If I remove IgnoreAllDefaultArgs and try it doesn't maximize the window by default and when I try to maximize manually the viewport size is not matching with my monitior size. And my test runs fine.
Why can't I pass the args.. which I want?
You don't need to remove all the arguments when you want to maximise the window. Its enough to do the following steps:
"--start-maximized"
as a browser launch arg (don't use IgnoreAllDefaultArgs)ViewportSize: ViewportSize.NoViewport
when creating your context.You can pass custom args, but some arguments are required to run Playwright.
We strongly recommend to run tests with a fixed viewport, since on your CI or coworkers environment the screen resolution might be different and your site which you are testing will behave differently.
You don't need to remove all the arguments when you want to maximise the window. Its enough to do the following steps:
- Pass
"--start-maximized"
as a browser launch arg (don't use IgnoreAllDefaultArgs)- Set
ViewportSize: ViewportSize.NoViewport
when creating your context.You can pass custom args, but some arguments are required to run Playwright.
We strongly recommend to run tests with a fixed viewport, since on your CI or coworkers environment the screen resolution might be different and your site which you are testing will behave differently.
Thank you. Above prescribed solution worked. Hence I suggest you to close the ticket.
var playwright = await Microsoft.Playwright.Playwright.CreateAsync();
var headless = Convert.ToBoolean(ConfigurationData.GetAppSetting("HeadlessModeEnabled"));
IBrowser? browser;
if (!headless)
{
browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions
{
Headless = headless,
Args = new[]
{
"--start-maximized"
}
});
var context = await browser.NewContextAsync(new BrowserNewContextOptions() { ViewportSize = ViewportSize.NoViewport });
_Page = await context.NewPageAsync();
}
else
{
browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions
{
Headless = headless
});
_Page = await browser.NewPageAsync();
}
_Page.SetDefaultTimeout((float)60000);
return _Page;
My application has three mode (mobile, tablet and computer) and in each of this mode the application has different options hence I was looking for computer option.
Source code
` var playwright = await Microsoft.Playwright.Playwright.CreateAsync(); var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions { Headless = false, IgnoreAllDefaultArgs = true, Args = new[] { "--disable-field-trial-config", "--disable-background-networking", "--enable-features=NetworkService,NetworkServiceInProcess", "--disable-background-timer-throttling", "--disable-backgrounding-occluded-windows", "--disable-back-forward-cache", "--disable-breakpad", "--disable-client-side-phishing-detection", "--disable-component-extensions-with-background-pages", "--disable-default-apps", "--disable-dev-shm-usage", "--disable-extensions", "--disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate", "--allow-pre-commit-input", "--disable-hang-monitor", "--disable-ipc-flooding-protection", "--disable-popup-blocking", "--disable-prompt-on-repost", "--disable-renderer-backgrounding", "--disable-sync", "--force-color-profile=srgb", "--metrics-recording-only", "--no-first-run", "--enable-automation", "--password-store=basic", "--use-mock-keychain", "--no-service-autorun", "--export-tagged-pdf"