|
| 1 | +// Licensed to the Software Freedom Conservancy (SFC) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The SFC licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +package org.openqa.selenium.firefox; |
| 19 | + |
| 20 | +import org.openqa.selenium.Beta; |
| 21 | +import org.openqa.selenium.Capabilities; |
| 22 | +import org.openqa.selenium.WebDriverException; |
| 23 | +import org.openqa.selenium.firefox.internal.MarionetteConnection; |
| 24 | +import org.openqa.selenium.internal.Lock; |
| 25 | + |
| 26 | +/** |
| 27 | + * An implementation of the {#link WebDriver} interface that drives Firefox using Marionette interface. |
| 28 | + */ |
| 29 | +@Beta |
| 30 | +public class MarionetteDriver extends FirefoxDriver { |
| 31 | + |
| 32 | + public MarionetteDriver() { |
| 33 | + this(new FirefoxBinary(), null); |
| 34 | + } |
| 35 | + |
| 36 | + public MarionetteDriver(FirefoxProfile profile) { |
| 37 | + super(profile); |
| 38 | + } |
| 39 | + |
| 40 | + public MarionetteDriver(Capabilities desiredCapabilities) { |
| 41 | + super(desiredCapabilities); |
| 42 | + } |
| 43 | + |
| 44 | + public MarionetteDriver(Capabilities desiredCapabilities, Capabilities requiredCapabilities) { |
| 45 | + super(desiredCapabilities, requiredCapabilities); |
| 46 | + } |
| 47 | + |
| 48 | + public MarionetteDriver(FirefoxBinary binary, FirefoxProfile profile) { |
| 49 | + super(binary, profile); |
| 50 | + } |
| 51 | + |
| 52 | + public MarionetteDriver(FirefoxBinary binary, FirefoxProfile profile, Capabilities capabilities) { |
| 53 | + super(binary, profile, capabilities); |
| 54 | + } |
| 55 | + |
| 56 | + public MarionetteDriver(FirefoxBinary binary, FirefoxProfile profile, |
| 57 | + Capabilities desiredCapabilities, Capabilities requiredCapabilities) { |
| 58 | + super(binary, profile, desiredCapabilities, requiredCapabilities); |
| 59 | + } |
| 60 | + |
| 61 | + protected ExtensionConnection connectTo(FirefoxBinary binary, FirefoxProfile profile, |
| 62 | + String host) { |
| 63 | + Lock lock = obtainLock(profile); |
| 64 | + try { |
| 65 | + FirefoxBinary bin = binary == null ? new FirefoxBinary() : binary; |
| 66 | + |
| 67 | + return new MarionetteConnection(lock, bin, profile, host); |
| 68 | + } catch (Exception e) { |
| 69 | + throw new WebDriverException(e); |
| 70 | + } |
| 71 | + } |
| 72 | +} |
0 commit comments