Skip to content

Commit 773f73a

Browse files
committed
redo all of this so that environment variable includes file name
1 parent a52db48 commit 773f73a

File tree

5 files changed

+24
-37
lines changed

5 files changed

+24
-37
lines changed

Diff for: dotnet/src/webdriver/SeleniumManager.cs

+8-15
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,24 @@ static SeleniumManager()
4040
{
4141
var currentDirectory = AppContext.BaseDirectory;
4242

43-
string binary;
4443
string file = "selenium-manager";
45-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
44+
string binary = $"selenium-manager/linux/{file}";
45+
46+
if (Environment.GetEnvironmentVariable("SE_MANAGER_PATH") != null)
4647
{
47-
file = "selenium-manager.exe";
48-
binary = $"selenium-manager/windows/{file}";
48+
binaryFullPath = Environment.GetEnvironmentVariable("SE_MANAGER_PATH");
4949
}
50-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
50+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
5151
{
52-
binary = $"selenium-manager/linux/{file}";
52+
file = "selenium-manager.exe";
53+
binary = $"selenium-manager/windows/{file}";
5354
}
5455
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
5556
{
5657
binary = $"selenium-manager/macos/{file}";
5758
}
58-
else
59-
{
60-
throw new WebDriverException("Selenium Manager did not find supported operating system");
61-
}
6259

63-
if (Environment.GetEnvironmentVariable("SE_MANAGER_PATH") != null)
64-
{
65-
binaryFullPath = Path.Combine(Environment.GetEnvironmentVariable("SE_MANAGER_PATH"), file);
66-
}
67-
else
60+
if (binaryFullPath == null)
6861
{
6962
binaryFullPath = Path.Combine(currentDirectory, binary);
7063
}

Diff for: java/src/org/openqa/selenium/manager/SeleniumManager.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ private synchronized Path getBinary() {
171171
}
172172
String binaryPath;
173173
if (System.getenv("SE_MANAGER_PATH") != null) {
174-
folder = System.getenv("SE_MANAGER_PATH");
175-
binary = Paths.get(String.format("%s/%s%s", folder, SELENIUM_MANAGER, extension));
174+
binary = Paths.get(System.getenv("SE_MANAGER_PATH"));
176175
} else {
177176
binaryPath = String.format("%s/%s%s", folder, SELENIUM_MANAGER, extension);
178177
try (InputStream inputStream = this.getClass().getResourceAsStream(binaryPath)) {

Diff for: javascript/node/selenium-webdriver/common/seleniumManager.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ function getBinary() {
4444
const file =
4545
directory === 'windows' ? 'selenium-manager.exe' : 'selenium-manager'
4646

47-
const seleniumManagerBasePath = process.env.SE_MANAGER_PATH || path.join(__dirname, '..', '/bin', directory)
47+
let seleniumManagerBasePath = path.join(__dirname, '..', '/bin')
4848

49-
const filePath = path.join(seleniumManagerBasePath, file)
49+
const filePath = process.env.SE_MANAGER_PATH || path.join(seleniumManagerBasePath, directory, file)
5050

5151
if (!fs.existsSync(filePath)) {
5252
throw new Error(`Unable to obtain Selenium Manager at ${filePath}`)

Diff for: py/selenium/webdriver/common/selenium_manager.py

+10-15
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,18 @@ def get_binary() -> Path:
4040
4141
:Returns: The Selenium Manager executable location
4242
"""
43-
platform = sys.platform
44-
45-
dirs = {
46-
"darwin": "macos",
47-
"win32": "windows",
48-
"cygwin": "windows",
49-
}
50-
51-
directory = dirs.get(platform) if dirs.get(platform) else platform
52-
53-
file = "selenium-manager.exe" if directory == "windows" else "selenium-manager"
54-
43+
directory = "linux"
44+
file = "selenium-manager"
5545
if os.getenv("SE_MANAGER_PATH"):
5646
directory = os.getenv("SE_MANAGER_PATH")
57-
path = f"{Path(directory)}/{file}"
58-
else:
59-
path = Path(__file__).parent.joinpath(directory, file)
47+
file = ""
48+
if sys.platform == "darwin":
49+
directory = "macos"
50+
elif sys.platform in ("win32", "cygwin"):
51+
directory = "windows"
52+
file = "selenium-manager.exe"
53+
54+
path = Path(__file__).parent.joinpath(directory, file)
6055

6156
if not path.is_file() and os.environ["CONDA_PREFIX"]:
6257
# conda has a separate package selenium-manager, installs in bin

Diff for: rb/lib/selenium/webdriver/common/selenium_manager.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class << self
3131
attr_writer :bin_path
3232

3333
def bin_path
34-
@bin_path ||= ENV.fetch('SE_MANAGER_PATH', '../../../../../bin')
34+
@bin_path ||= '../../../../../bin'
3535
end
3636

3737
# @param [Options] options browser options.
@@ -80,10 +80,10 @@ def binary
8080
'/windows/selenium-manager.exe'
8181
elsif Platform.mac?
8282
'/macos/selenium-manager'
83-
elsif Platform.linux?
83+
else
8484
'/linux/selenium-manager'
8585
end
86-
location = File.expand_path(path, __FILE__)
86+
location = ENV.fetch('SE_MANAGER_PATH', File.expand_path(path, __FILE__))
8787

8888
begin
8989
Platform.assert_file(location)

0 commit comments

Comments
 (0)