Skip to content

Commit

Permalink
[#262] fixed sonar issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry.bogatko committed Sep 17, 2024
1 parent 41eabbf commit 8bf996c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ namespace Aquality.Selenium.Browsers
{
public class DriverContext
{
public WebDriver Driver { get; set; }
public DriverContext(WebDriver driver)
{
Driver = driver;
}

public WebDriver Driver { get; }
public DriverService? DriverService { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ private DriverContext GetDriver<T>(Func<DriverService> driverServiceProvider, Dr
{
var driverService = driverServiceProvider.Invoke();
var driver = (T)Activator.CreateInstance(typeof(T), driverService, driverOptions, commandTimeout);
var context = new DriverContext
var context = new DriverContext(driver)
{
Driver = driver,
DriverService = driverService
};
return context;
Expand All @@ -110,9 +109,8 @@ private DriverContext GetDriver<T>(Func<DriverService> driverServiceProvider, Dr
Environment.SetEnvironmentVariable(DriverVersionVariableName, currentVersion);
var driverService = driverServiceProvider.Invoke();
var driver = (T)Activator.CreateInstance(typeof(T), driverService, driverOptions, commandTimeout);
var context = new DriverContext
var context = new DriverContext(driver)
{
Driver = driver,
DriverService = driverService
};
return context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ protected override DriverContext DriverContext
try
{
var driver = new RemoteWebDriver(BrowserProfile.RemoteConnectionUrl, capabilities, TimeoutConfiguration.Command);
var context = new DriverContext
{
Driver = driver,
DriverService = null
};
var context = new DriverContext(driver);
return context;
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ protected override DriverContext DriverContext {
SetUpDriver(new());
var driverService = ChromeDriverService.CreateDefaultService();
var driver = new ChromeDriver(driverService, (ChromeOptions)driverSettings.DriverOptions);
return new DriverContext
return new DriverContext(driver)
{
Driver = driver,
DriverService = driverService
};
}
Expand Down

0 comments on commit 8bf996c

Please sign in to comment.