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

selenium: add log for Firefox profile creation #6252

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion addOns/selenium/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Added
- Add debug log for the Firefox profile creation.

## [15.34.0] - 2025-02-27
### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,15 @@ private Path getProfilesDirectory() {
LOGGER.error(
"Do not know how to find Firefox directory for {}",
System.getProperty("os.name"));
return profileDirectory;
}
}
if (!profileDirectory.toFile().isDirectory()) {
LOGGER.debug(
"The profiles path is not a directory or does not exist: {}", profileDirectory);
profileDirectory = null;
} else {
LOGGER.debug("The profiles directory was found under: {}", profileDirectory);
}
return profileDirectory;
}
Expand Down Expand Up @@ -105,6 +110,7 @@ public List<String> getProfiles() {
.map(s -> s.substring(9))
.collect(Collectors.toList());
Collections.sort(profiles);
LOGGER.debug("Found profiles: {}", profiles);
}
return List.copyOf(profiles);
}
Expand All @@ -119,8 +125,11 @@ public Path getProfileDirectory(String profileName) {
Optional<String> fullName =
Arrays.stream(profileDir.toFile().list()).filter(p.asPredicate()).findFirst();
if (fullName.isPresent()) {
return profileDir.resolve(fullName.get());
Path dir = profileDir.resolve(fullName.get());
LOGGER.debug("Profile directory found for {} under: {}", profileName, dir);
return dir;
}
LOGGER.debug("Profile directory not found for {}", profileName);
return null;
}

Expand All @@ -132,11 +141,14 @@ public Path getOrCreateProfile(String profileName) throws IOException {
}
FirefoxOptions firefoxOptions = new FirefoxOptions();
String path = firefoxOptions.getBinary().getPath();
String[] args = {path, "-CreateProfile", profileName};
LOGGER.debug("Creating profile with: {}", () -> Arrays.toString(args));

Process ps = runtime.exec(new String[] {path, "-CreateProfile", profileName});
Process ps = runtime.exec(args);

try {
ps.waitFor();
int result = ps.waitFor();
LOGGER.debug("Executed Firefox with exit code: {}", result);
} catch (InterruptedException e) {
// Ignore
}
Expand Down