In Home controller I'm returning return View("Login", ReturnUrl);
In Views/Home/ there's Login.cshtml
Everything works fine when I manually start the app, but when I'm starting application in Selenium tests like that:
[Parallelizable]
[Test]
public async Task TEST()
{
var info = this.ConnectionInfo[Configure()];
foreach (var driver in GetDrivers())
{
var _context = GetDb(info.ConnectionString);
driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(15);
_context.Database.EnsureDeleted();
_context.Database.EnsureCreated();
driver.Navigate().GoToUrl(info.Address);
}
}
public Guid Configure()
{
var addressId = Guid.NewGuid();
var port1 = FreeTcpPort();
var port2 = FreeTcpPort();
var dbFileGuid = Guid.NewGuid().ToString("N") + ".db";
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
config["Tests:ConnectionString"] = $"Filename={dbFileGuid}";
_host = new WebHostBuilder()
.UseKestrel()
.UseConfiguration
(
config
)
.UseUrls($"http://localhost:{port1}/", $"https://localhost:{port2}/")
.UseStartup<TestsStartup>()
.UseSerilog()
.Build();
_host.StartAsync();
ConnectionInfo.TryAdd(addressId, new ConnectionInfo($"http://127.0.0.1:{port1}", dbFileGuid, _host));
return addressId;
}
TestStartup is using the same methods to configure ConfigureServices and Configure as my real config, with the difference in DatabaseContext provider.
Here's what appears during tests
Here are my parts of Startup
services
.AddControllersWithViews(x =>
{
x.Filters.Add(typeof(CustomExceptionFilter));
})
.AddNewtonsoftJson()
.AddApplicationPart(typeof(HomeController).Assembly)
.AddControllersAsServices()
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
services
.AddRazorPages()
.AddRazorRuntimeCompilation();
app.UseAuthentication();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute
(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}"
);
endpoints.MapRazorPages();
});
What may cause that App is unable to find those Views when started from Tests meanwhile it managed to do it on older .NET Core / older ASP libs?
