-
-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Hi,
Im very close to using this but there's only one thing stopping me. In Firefox, when I want to send a request with a header. Without this header, my request is going to fail.
I tried this:
final ProfilesIni pi = new ProfilesIni();
final FirefoxProfile profile = pi.getProfile("default");
profile.setPreference("browser.download.folderList",
2); // 0: Desktop, 1: Downloads, 2: Custom Location
final Path abs = downloadedFilePath.toAbsolutePath();
profile.setPreference("browser.download.dir", abs.toString());
final String commonPassword = repProperties.getCommonPassword();
final String usernamePassword = username + ":" + commonPassword;
final String encodedString = Base64.getEncoder().encodeToString(usernamePassword.getBytes());
// These prefs dont work.
/*profile.setPreference("modifyheaders.headers.count", 1);
profile.setPreference("modifyheaders.headers.action0", "Add");
profile.setPreference("modifyheaders.headers.name0", "Authorization");
profile.setPreference("modifyheaders.headers.value0", "Basic " + encodedString);
profile.setPreference("modifyheaders.headers.enabled0", true);
profile.setPreference("modifyheaders.config.active", true);
profile.setPreference("modifyheaders.config.alwaysOn", true);*/
// Neither do these.
profile.setPreference("modheader.headers.count", 1);
profile.setPreference("modheader.headers.action0", "Add");
profile.setPreference("modheader.headers.name0", "Authorization");
profile.setPreference("modheader.headers.value0", "Basic " + encodedString);
profile.setPreference("modheader.headers.enabled0", true);
profile.setPreference("modheader.headers.config.active", true);
profile.setPreference("modheader.headers.config.alwaysOn", true);
final FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setCapability("acceptInsecureCerts", true);
//firefoxOptions.setHeadless(true); sj_todo remove uncomment
firefoxOptions.setProfile(profile);
logger.debug("Creating reports at {}", abs);
final FirefoxDriver webDriver = new FirefoxDriver(firefoxOptions);
webDriver.installExtension("path-to-xpi");
return webDriver;
Another way is to load the modheader profile (that has the header I need) on startup. But I cant find a way to import automatically on startup either.
Any suggestions?
Thanks.
Metadata
Metadata
Assignees
Labels
No labels