How to use isLegacy method of org.openqa.selenium.firefox.FirefoxOptions class

Best Selenium code snippet using org.openqa.selenium.firefox.FirefoxOptions.isLegacy

Source:FirefoxOptionsTest.java Github

copy

Full Screen

...57 FirefoxOptions options = new FirefoxOptions(new ImmutableCapabilities(58 MARIONETTE, false,59 PAGE_LOAD_STRATEGY, PageLoadStrategy.EAGER,60 ACCEPT_INSECURE_CERTS, true));61 assertThat(options.isLegacy()).isTrue();62 assertThat(options.getCapability(PAGE_LOAD_STRATEGY)).isEqualTo(EAGER);63 assertThat(options.getCapability(ACCEPT_INSECURE_CERTS)).isEqualTo(true);64 }65 @Test66 public void canInitFirefoxOptionsWithCapabilitiesThatContainFirefoxOptions() {67 FirefoxOptions options = new FirefoxOptions().setLegacy(true).merge(68 new ImmutableCapabilities(PAGE_LOAD_STRATEGY, PageLoadStrategy.EAGER));69 Capabilities caps = new ImmutableCapabilities(FIREFOX_OPTIONS, options);70 FirefoxOptions options2 = new FirefoxOptions(caps);71 assertThat(options2.isLegacy()).isTrue();72 assertThat(options2.getCapability(PAGE_LOAD_STRATEGY)).isEqualTo(EAGER);73 }74 @Test75 public void canInitFirefoxOptionsWithCapabilitiesThatContainFirefoxOptionsAsMap() {76 FirefoxProfile profile = new FirefoxProfile();77 Capabilities caps = new ImmutableCapabilities(78 FIREFOX_OPTIONS, ImmutableMap.of("profile", profile));79 FirefoxOptions options = new FirefoxOptions(caps);80 assertThat(options.getProfile()).isSameAs(profile);81 }82 @Test83 public void binaryPathNeedNotExist() {84 new FirefoxOptions().setBinary("does/not/exist");85 }86 @Test87 public void shouldKeepRelativePathToBinaryAsIs() {88 FirefoxOptions options = new FirefoxOptions().setBinary("some/path");89 assertThat(options.getCapability(BINARY)).isEqualTo("some/path");90 }91 @Test92 public void shouldConvertPathToBinaryToUseForwardSlashes() {93 FirefoxOptions options = new FirefoxOptions().setBinary("some\\path");94 assertThat(options.getCapability(BINARY)).isEqualTo("some/path");95 }96 @Test97 public void shouldKeepWindowsDriveLetterInPathToBinary() {98 FirefoxOptions options = new FirefoxOptions().setBinary("F:\\some\\path");99 assertThat(options.getCapability(BINARY)).isEqualTo("F:/some/path");100 }101 @Test102 public void canUseForwardSlashesInWindowsPaths() {103 FirefoxOptions options = new FirefoxOptions().setBinary("F:\\some\\path");104 assertThat(options.getCapability(BINARY)).isEqualTo("F:/some/path");105 }106 @Test107 public void shouldKeepWindowsNetworkFileSystemRootInPathToBinary() {108 FirefoxOptions options = new FirefoxOptions().setBinary("\\\\server\\share\\some\\path");109 assertThat(options.getCapability(BINARY)).isEqualTo("//server/share/some/path");110 }111 @Test112 public void shouldKeepAFirefoxBinaryAsABinaryIfSetAsOne() throws IOException {113 File fakeExecutable = Files.createTempFile("firefox", ".exe").toFile();114 fakeExecutable.deleteOnExit();115 FirefoxBinary binary = new FirefoxBinary(fakeExecutable);116 FirefoxOptions options = new FirefoxOptions().setBinary(binary);117 assertThat(options.getCapability(BINARY)).isEqualTo(binary);118 assertThat(options.getBinary()).isEqualTo(binary);119 }120 @Test121 public void stringBasedBinaryRemainsAbsoluteIfSetAsAbsolute() {122 Map<String, Object> json = new FirefoxOptions().setBinary("/i/like/cheese").asMap();123 assertThat(((Map<?, ?>) json.get(FIREFOX_OPTIONS)).get("binary")).isEqualTo("/i/like/cheese");124 }125 @Test126 public void pathBasedBinaryRemainsAbsoluteIfSetAsAbsolute() {127 Map<String, Object> json = new FirefoxOptions().setBinary(Paths.get("/i/like/cheese")).asMap();128 assertThat(((Map<?, ?>) json.get(FIREFOX_OPTIONS)).get("binary")).isEqualTo("/i/like/cheese");129 }130 @Test131 public void shouldPickUpBinaryFromSystemPropertyIfSet() throws IOException {132 JreSystemProperty property = new JreSystemProperty(BROWSER_BINARY);133 Path binary = Files.createTempFile("firefox", ".exe");134 try (OutputStream ignored = Files.newOutputStream(binary, DELETE_ON_CLOSE)) {135 Files.write(binary, "".getBytes());136 if (! TestUtilities.getEffectivePlatform().is(Platform.WINDOWS)) {137 Files.setPosixFilePermissions(binary, ImmutableSet.of(PosixFilePermission.OWNER_EXECUTE));138 }139 property.set(binary.toString());140 FirefoxOptions options = new FirefoxOptions();141 FirefoxBinary firefoxBinary =142 options.getBinaryOrNull().orElseThrow(() -> new AssertionError("No binary"));143 assertThat(firefoxBinary.getPath()).isEqualTo(binary.toString());144 } finally {145 property.reset();146 }147 }148 @Test149 public void shouldPickUpLegacyValueFromSystemProperty() {150 JreSystemProperty property = new JreSystemProperty(DRIVER_USE_MARIONETTE);151 try {152 // No value should default to using Marionette153 property.set(null);154 FirefoxOptions options = new FirefoxOptions();155 assertThat(options.isLegacy()).isFalse();156 property.set("false");157 options = new FirefoxOptions();158 assertThat(options.isLegacy()).isTrue();159 property.set("true");160 options = new FirefoxOptions();161 assertThat(options.isLegacy()).isFalse();162 } finally {163 property.reset();164 }165 }166 @Test167 public void settingMarionetteToFalseAsASystemPropertyDoesNotPrecedence() {168 JreSystemProperty property = new JreSystemProperty(DRIVER_USE_MARIONETTE);169 try {170 Capabilities caps = new ImmutableCapabilities(MARIONETTE, true);171 property.set("false");172 FirefoxOptions options = new FirefoxOptions().merge(caps);173 assertThat(options.isLegacy()).isFalse();174 } finally {175 property.reset();176 }177 }178 @Test179 public void shouldPickUpProfileFromSystemProperty() {180 FirefoxProfile defaultProfile = new ProfilesIni().getProfile("default");181 assumeThat(defaultProfile).isNotNull();182 JreSystemProperty property = new JreSystemProperty(BROWSER_PROFILE);183 try {184 property.set("default");185 FirefoxOptions options = new FirefoxOptions();186 FirefoxProfile profile = options.getProfile();187 assertThat(profile).isNotNull();...

Full Screen

Full Screen

Selenium 4 Tutorial:

LambdaTest’s Selenium 4 tutorial is covering every aspects of Selenium 4 testing with examples and best practices. Here you will learn basics, such as how to upgrade from Selenium 3 to Selenium 4, to some advanced concepts, such as Relative locators and Selenium Grid 4 for Distributed testing. Also will learn new features of Selenium 4, such as capturing screenshots of specific elements, opening a new tab or window on the browser, and new protocol adoptions.

Chapters:

  1. Upgrading From Selenium 3 To Selenium 4?: In this chapter, learn in detail how to update Selenium 3 to Selenium 4 for Java binding. Also, learn how to upgrade while using different build tools such as Maven or Gradle and get comprehensive guidance for upgrading Selenium.

  2. What’s New In Selenium 4 & What’s Being Deprecated? : Get all information about new implementations in Selenium 4, such as W3S protocol adaption, Optimized Selenium Grid, and Enhanced Selenium IDE. Also, learn what is deprecated for Selenium 4, such as DesiredCapabilites and FindsBy methods, etc.

  3. Selenium 4 With Python: Selenium supports all major languages, such as Python, C#, Ruby, and JavaScript. In this chapter, learn how to install Selenium 4 for Python and the features of Python in Selenium 4, such as Relative locators, Browser manipulation, and Chrom DevTool protocol.

  4. Selenium 4 Is Now W3C Compliant: JSON Wireframe protocol is retiring from Selenium 4, and they are adopting W3C protocol to learn in detail about the advantages and impact of these changes.

  5. How To Use Selenium 4 Relative Locator? : Selenium 4 came with new features such as Relative Locators that allow constructing locators with reference and easily located constructors nearby. Get to know its different use cases with examples.

  6. Selenium Grid 4 Tutorial For Distributed Testing: Selenium Grid 4 allows you to perform tests over different browsers, OS, and device combinations. It also enables parallel execution browser testing, reads up on various features of Selenium Grid 4 and how to download it, and runs a test on Selenium Grid 4 with best practices.

  7. Selenium Video Tutorials: Binge on video tutorials on Selenium by industry experts to get step-by-step direction from automating basic to complex test scenarios with Selenium.

Selenium 101 certifications:

LambdaTest also provides certification for Selenium testing to accelerate your career in Selenium automation testing.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful