-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "[java] Remove Opera related classes (#10950)"
This reverts commit 9955c13.
- Loading branch information
Showing
13 changed files
with
850 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
load("//java:defs.bzl", "java_export") | ||
load("//java:version.bzl", "SE_VERSION") | ||
|
||
java_export( | ||
name = "opera", | ||
srcs = glob(["*.java"]), | ||
maven_coordinates = "org.seleniumhq.selenium:selenium-opera-driver:%s" % SE_VERSION, | ||
pom_template = "//java/src/org/openqa/selenium:template-pom", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//java:auto-service", | ||
"//java/src/org/openqa/selenium:core", | ||
"//java/src/org/openqa/selenium/remote", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.opera; | ||
|
||
import org.openqa.selenium.Capabilities; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebDriverException; | ||
import org.openqa.selenium.html5.LocalStorage; | ||
import org.openqa.selenium.html5.Location; | ||
import org.openqa.selenium.html5.LocationContext; | ||
import org.openqa.selenium.html5.SessionStorage; | ||
import org.openqa.selenium.html5.WebStorage; | ||
import org.openqa.selenium.remote.FileDetector; | ||
import org.openqa.selenium.remote.RemoteWebDriver; | ||
import org.openqa.selenium.remote.html5.RemoteLocationContext; | ||
import org.openqa.selenium.remote.html5.RemoteWebStorage; | ||
import org.openqa.selenium.remote.service.DriverCommandExecutor; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* A {@link WebDriver} implementation that controls a Blink-based Opera browser running on the local | ||
* machine. It requires an <code>operadriver</code> executable to be available in PATH. | ||
* | ||
* @see <a href="https://github.com/operasoftware/operachromiumdriver">operadriver</a> | ||
* | ||
* Since operadriver does not support w3c, Selenium will remove the support in the next version. | ||
* @deprecated Use {@link org.openqa.selenium.chrome.ChromeDriver} with | ||
* {@link org.openqa.selenium.chrome.ChromeOptions#setBinary(File)} or {@link org.openqa.selenium.chrome.ChromeOptions#setBinary(String)} | ||
* to set the path to the Opera browser. | ||
* | ||
* <p>Example usage: | ||
* <pre><code> | ||
* ChromeOptions options = new ChromeOptions() | ||
* options.setBinary(new File("/path/to/opera")); | ||
* | ||
* // For using Opera browser with ChromeDriver: | ||
* ChromeDriver driver = new ChromeDriver(options); | ||
* | ||
* // For use with RemoteWebDriver: | ||
* ChromeOptions options = new ChromeOptions(); | ||
* options.setBinary(new File("/path/to/opera")); | ||
* RemoteWebDriver driver = new RemoteWebDriver( | ||
* new URL("http://localhost:4444/"), options); | ||
* </code></pre> | ||
*/ | ||
@Deprecated | ||
public class OperaDriver extends RemoteWebDriver | ||
implements LocationContext, WebStorage { | ||
|
||
private RemoteLocationContext locationContext; | ||
private RemoteWebStorage webStorage; | ||
|
||
/** | ||
* Creates a new OperaDriver using the {@link OperaDriverService#createDefaultService default} | ||
* server configuration. | ||
* | ||
* @see #OperaDriver(OperaDriverService, OperaOptions) | ||
*/ | ||
public OperaDriver() { | ||
this(OperaDriverService.createDefaultService(), new OperaOptions()); | ||
} | ||
|
||
/** | ||
* Creates a new OperaDriver instance. The {@code service} will be started along with the driver, | ||
* and shutdown upon calling {@link #quit()}. | ||
* | ||
* @param service The service to use. | ||
* @see #OperaDriver(OperaDriverService, OperaOptions) | ||
*/ | ||
public OperaDriver(OperaDriverService service) { | ||
this(service, new OperaOptions()); | ||
} | ||
|
||
/** | ||
* Creates a new OperaDriver instance. The {@code capabilities} will be passed to the | ||
* chromedriver service. | ||
* | ||
* @param capabilities The capabilities required from the OperaDriver. | ||
* @see #OperaDriver(OperaDriverService, Capabilities) | ||
* @deprecated Use {@link #OperaDriver(OperaOptions)} instead. | ||
*/ | ||
@Deprecated | ||
public OperaDriver(Capabilities capabilities) { | ||
this(OperaDriverService.createDefaultService(), capabilities); | ||
} | ||
|
||
/** | ||
* Creates a new OperaDriver instance with the specified options. | ||
* | ||
* @param options The options to use. | ||
* @see #OperaDriver(OperaDriverService, OperaOptions) | ||
*/ | ||
public OperaDriver(OperaOptions options) { | ||
this(OperaDriverService.createDefaultService(), options); | ||
} | ||
|
||
/** | ||
* Creates a new OperaDriver instance with the specified options. The {@code service} will be | ||
* started along with the driver, and shutdown upon calling {@link #quit()}. | ||
* | ||
* @param service The service to use. | ||
* @param options The options to use. | ||
*/ | ||
public OperaDriver(OperaDriverService service, OperaOptions options) { | ||
this(service, (Capabilities) options); | ||
} | ||
|
||
/** | ||
* Creates a new OperaDriver instance. The {@code service} will be started along with the | ||
* driver, and shutdown upon calling {@link #quit()}. | ||
* | ||
* @param service The service to use. | ||
* @param capabilities The capabilities required from the OperaDriver. | ||
* @deprecated Use {@link #OperaDriver(OperaDriverService, OperaOptions)} instead. | ||
*/ | ||
@Deprecated | ||
public OperaDriver(OperaDriverService service, Capabilities capabilities) { | ||
super(new DriverCommandExecutor(service), capabilities); | ||
locationContext = new RemoteLocationContext(getExecuteMethod()); | ||
webStorage = new RemoteWebStorage(getExecuteMethod()); | ||
} | ||
|
||
@Override | ||
public void setFileDetector(FileDetector detector) { | ||
throw new WebDriverException( | ||
"Setting the file detector only works on remote webdriver instances obtained " + | ||
"via RemoteWebDriver"); | ||
} | ||
|
||
@Override | ||
public LocalStorage getLocalStorage() { | ||
return webStorage.getLocalStorage(); | ||
} | ||
|
||
@Override | ||
public SessionStorage getSessionStorage() { | ||
return webStorage.getSessionStorage(); | ||
} | ||
|
||
@Override | ||
public Location location() { | ||
return locationContext.location(); | ||
} | ||
|
||
@Override | ||
public void setLocation(Location location) { | ||
locationContext.setLocation(location); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.opera; | ||
|
||
import com.google.auto.service.AutoService; | ||
|
||
import org.openqa.selenium.Capabilities; | ||
import org.openqa.selenium.ImmutableCapabilities; | ||
import org.openqa.selenium.SessionNotCreatedException; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebDriverException; | ||
import org.openqa.selenium.WebDriverInfo; | ||
|
||
import java.util.Optional; | ||
|
||
import static org.openqa.selenium.remote.Browser.OPERA; | ||
import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME; | ||
|
||
@AutoService(WebDriverInfo.class) | ||
public class OperaDriverInfo implements WebDriverInfo { | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return "Opera"; | ||
} | ||
|
||
@Override | ||
public Capabilities getCanonicalCapabilities() { | ||
return new ImmutableCapabilities(BROWSER_NAME, OPERA.browserName()); | ||
} | ||
|
||
@Override | ||
public boolean isSupporting(Capabilities capabilities) { | ||
return OPERA.is(capabilities.getBrowserName()); | ||
} | ||
|
||
@Override | ||
public boolean isSupportingCdp() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isAvailable() { | ||
try { | ||
OperaDriverService.createDefaultService(); | ||
return true; | ||
} catch (IllegalStateException | WebDriverException e) { | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public int getMaximumSimultaneousSessions() { | ||
return Runtime.getRuntime().availableProcessors(); | ||
} | ||
|
||
@Override | ||
public Optional<WebDriver> createDriver(Capabilities capabilities) | ||
throws SessionNotCreatedException { | ||
if (!isAvailable()) { | ||
return Optional.empty(); | ||
} | ||
|
||
return Optional.of(new OperaDriver(capabilities)); | ||
} | ||
} |
Oops, something went wrong.