Merge pull request #962 from visagang/features/vguruparan

Update default timeout for web driver
This commit is contained in:
Haiping 2025-03-21 16:29:45 -05:00 committed by GitHub
commit 4c62ce18f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View file

@ -6,6 +6,7 @@ public class WebBrowsingSettings
public bool Headless { get; set; }
// Default timeout in milliseconds
public float DefaultTimeout { get; set; } = 30000;
public float DefaultNavigationTimeout { get; set; } = 30000;
public bool IsEnableScreenshot { get; set; }
// Default wait time in seconds after page is opened
public int DefaultWaitTime { get; set; } = 5;

View file

@ -45,6 +45,7 @@ public class PlaywrightInstance : IDisposable
public async Task<IBrowserContext> InitContext(string ctxId, BrowserActionArgs args)
{
var _webDriver = _services.GetRequiredService<WebBrowsingSettings>();
if (_contexts.ContainsKey(ctxId))
return _contexts[ctxId];
@ -83,6 +84,8 @@ public class PlaywrightInstance : IDisposable
// "--start-maximized"
]
});
_contexts[ctxId].SetDefaultTimeout(_webDriver.DefaultTimeout);
_contexts[ctxId].SetDefaultNavigationTimeout(_webDriver.DefaultNavigationTimeout);
}
_pages[ctxId] = new List<IPage>();