Cannot convert lambda to intended delegate because some of the return types in the block are not implicitly converted to the delegate return type.
without DI
var chromeDriverService = ChromeDriverService.CreateDefaultService();
var chromeOptions = new ChromeOptions();
chromeOptions.AddArguments(new List<string>() { "headless" });
ChromeDriver driver = new ChromeDriver(chromeDriverService, chromeOptions);
with DI in Startup.cs
services.AddScoped<ChromeDriverService>((serviceProvider =>
{
return ChromeDriverService.CreateDefaultService();
}));
//**** errors here*****
services.AddScoped<ChromeOptions>((serviceProvider =>
{ return new ChromeOptions().AddArguments(new List<string>() { "headless" }); }));
// errors here******
// how would i pass the driver service & options
services.AddScoped<ChromeDriver>(
(serviceProvider =>
{
return new ChromeDriver(chromeDriverService,chromeOptions);
}));
how do i make it so it's convertible and pass the correct options to the chromeDriver ?
.AddArguments(...);return? Is it an instance ofChromeOptions?Chrome OptionsandChromeDiverServiceapart fromChromeDriver? if so, you may want to consider registering onlyChromeDriver