I'm using Selenium, I make many calls to INavigation
's GoToUrl
method throghout the application. The second call causes it to crash the application, or exit with exit code 0, no exception given.
It's got path for execution, I've attached a debugger to the exact line, even running through immediate window also crashes it.
I've since understood that its because of my usage of https://github.com/commandlineparser/commandline and letting it handle the execution, although why is this happening? Is it a bug of the package?
Option A - Works fine (no crash)
public static async Task Main(string[] args)
{
var host = Host.CreateDefaultBuilder()
.ConfigureServices((context, collection) => ServiceCollection.AddServices(collection, context.Configuration))
.Build();
var commandHandler = host.Services.GetRequiredService<CommandHandler>();
var options = new BasicReportOptions()
{
UrlsToCheckFile = "...",
DuplicateUrlsToCheckFile = "...",
FocusedPhrasesFile = "...",
};
await commandHandler.HandleBasicReport(options);
}
Option B - Doesn't work (crashes) with the difference being the call to CommandHandler
's HandleInputAsync
(below) being called instead of the actual method.
public static async Task Main(string[] args)
{
var host = Host.CreateDefaultBuilder()
.ConfigureServices((context, collection) => ServiceCollection.AddServices(collection, context.Configuration))
.Build();
var commandHandler = host.Services.GetRequiredService<CommandHandler>();
await commandHandler.HandleInputAsync(args);
}
HandleInputAsync
:
public async Task HandleInputAsync(string[] args)
{
Parser.Default.ParseArguments<BasicReportOptions, ExtensiveReportOptions>(args)
.WithParsed<BasicReportOptions>(async options => await HandleBasicReport(options))
.WithParsed<ExtensiveReportOptions>(async options => await HandleExtensiveReport(options));
}
So it seems to me that, when using HandleInputAsync
and calling the methods without WithParsed
, causes calls to Selenium's IWebDriver to crash?