Starta inte ny chromedriver för varje anrop

This commit is contained in:
2021-02-10 07:21:00 +01:00
parent e4fee01015
commit d3b28ae51a
2 changed files with 11 additions and 7 deletions

View File

@ -21,8 +21,6 @@ namespace StockDal
public StringBuilder TextResults { get; set; }
public bool ViewBrowser { get; set; }
public IWebDriver driver;
public StockMarketRepository()
@ -160,13 +158,19 @@ namespace StockDal
if (ViewBrowser)
{
driver = new ChromeDriver(driverService);
if (driver == null)
{
driver = new ChromeDriver(driverService);
}
}
else
{
var options = new ChromeOptions();
options.AddArgument("headless");
driver = new ChromeDriver(driverService, options);
if (driver == null)
{
var options = new ChromeOptions();
options.AddArgument("headless");
driver = new ChromeDriver(driverService, options);
}
}
try