|
43 | 43 | import org.junit.Test;
|
44 | 44 | import org.openqa.selenium.Capabilities;
|
45 | 45 | import org.openqa.selenium.ImmutableCapabilities;
|
| 46 | +import org.openqa.selenium.MutableCapabilities; |
46 | 47 | import org.openqa.selenium.PageLoadStrategy;
|
47 | 48 | import org.openqa.selenium.Platform;
|
48 | 49 | import org.openqa.selenium.WebDriverException;
|
|
57 | 58 | import java.nio.file.Path;
|
58 | 59 | import java.nio.file.Paths;
|
59 | 60 | import java.nio.file.attribute.PosixFilePermission;
|
| 61 | +import java.util.Arrays; |
60 | 62 | import java.util.Map;
|
61 | 63 |
|
62 | 64 | public class FirefoxOptionsTest {
|
@@ -278,4 +280,39 @@ public void canBuildLogLevelFromStringRepresentation() {
|
278 | 280 | assertEquals(FirefoxDriverLogLevel.fromString("ERROR"), FirefoxDriverLogLevel.ERROR);
|
279 | 281 | }
|
280 | 282 |
|
| 283 | + @Test |
| 284 | + public void canConvertOptionsWithArgsToCapabilitiesAndRestoreBack() { |
| 285 | + FirefoxOptions options = new FirefoxOptions( |
| 286 | + new MutableCapabilities(new FirefoxOptions().addArguments("-a", "-b"))); |
| 287 | + Object options2 = options.asMap().get(FirefoxOptions.FIREFOX_OPTIONS); |
| 288 | + assertNotNull(options2); |
| 289 | + assertEquals(((Map<String, Object>) options2).get("args"), Arrays.asList("-a", "-b")); |
| 290 | + } |
| 291 | + |
| 292 | + @Test |
| 293 | + public void canConvertOptionsWithPrefsToCapabilitiesAndRestoreBack() { |
| 294 | + FirefoxOptions options = new FirefoxOptions( |
| 295 | + new MutableCapabilities(new FirefoxOptions() |
| 296 | + .addPreference("string.pref", "some value") |
| 297 | + .addPreference("int.pref", 42) |
| 298 | + .addPreference("boolean.pref", true))); |
| 299 | + Object options2 = options.asMap().get(FirefoxOptions.FIREFOX_OPTIONS); |
| 300 | + assertNotNull(options2); |
| 301 | + Object prefs = ((Map<String, Object>) options2).get("prefs"); |
| 302 | + assertNotNull(prefs); |
| 303 | + assertEquals(((Map<String, Object>) prefs).get("string.pref"), "some value"); |
| 304 | + assertEquals(((Map<String, Object>) prefs).get("int.pref"), 42); |
| 305 | + assertEquals(((Map<String, Object>) prefs).get("boolean.pref"), true); |
| 306 | + } |
| 307 | + |
| 308 | + @Test |
| 309 | + public void canConvertOptionsWithBinaryToCapabilitiesAndRestoreBack() { |
| 310 | + FirefoxOptions options = new FirefoxOptions( |
| 311 | + new MutableCapabilities(new FirefoxOptions().setBinary(new FirefoxBinary()))); |
| 312 | + Object options2 = options.asMap().get(FirefoxOptions.FIREFOX_OPTIONS); |
| 313 | + assertNotNull(options2); |
| 314 | + assertEquals(((Map<String, Object>) options2).get("binary"), |
| 315 | + new FirefoxBinary().getPath().replaceAll("\\\\", "/")); |
| 316 | + } |
| 317 | + |
281 | 318 | }
|
0 commit comments