Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to set TempDirectory #291

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WebDriverManager.Tests/BinaryServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void NoProxyBySystemVariable()
public void DownloadZipResultNotEmpty()
{
const string url = "https://chromedriver.storage.googleapis.com/2.27/chromedriver_win32.zip";
var destination = FileHelper.GetZipDestination(url);
var destination = FileHelper.GetZipDestination(url, null);
radmorecameron marked this conversation as resolved.
Show resolved Hide resolved
FileHelper.CreateDestinationDirectory(destination);
var result = DownloadZip(url, destination);
Assert.NotEmpty(result);
Expand Down
8 changes: 7 additions & 1 deletion WebDriverManager/DriverManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class DriverManager
private IBinaryService _binaryService;
private readonly IVariableService _variableService;
private string _downloadDirectory = Directory.GetCurrentDirectory();
private string _tmpPathDirectory = Path.GetTempPath();

public DriverManager()
{
Expand Down Expand Up @@ -75,9 +76,14 @@ public string SetUpDriver(string url, string binaryPath)
}
}

public void SetTempPathDirectory(string tempPath)
{
_tmpPathDirectory = tempPath;
}

private string SetUpDriverImpl(string url, string binaryPath)
{
var zipPath = FileHelper.GetZipDestination(url);
var zipPath = FileHelper.GetZipDestination(url, _tmpPathDirectory);
binaryPath = _binaryService.SetupBinary(url, zipPath, binaryPath);
_variableService.SetupVariable(binaryPath);
return binaryPath;
Expand Down
5 changes: 2 additions & 3 deletions WebDriverManager/Helpers/FileHelper.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using System;
using System;
using System.IO;

namespace WebDriverManager.Helpers
{
public static class FileHelper
{
public static string GetZipDestination(string url)
public static string GetZipDestination(string url, string tempDirectory)
{
var tempDirectory = Path.GetTempPath();
var guid = Guid.NewGuid().ToString();
var zipName = Path.GetFileName(url);
if (zipName == null) throw new ArgumentNullException($"Can't get zip name from URL: {url}");
Expand Down