diff --git a/dotnet/AGENTS.md b/dotnet/AGENTS.md
index 81c7b1766a874..2c48e93d2f7db 100644
--- a/dotnet/AGENTS.md
+++ b/dotnet/AGENTS.md
@@ -28,6 +28,14 @@ _logger.Debug("diagnostic: request details for debugging");
[Obsolete("Use NewMethod instead")]
public void OldMethod() { }
```
+When code inside the assembly must still reference an obsolete member (e.g. a field
+or method the obsolete API is built on), wrap just that usage to keep the build
+warning-clean (see `UserPromptHandler.cs`):
+```csharp
+#pragma warning disable CS0618 // Type or member is obsolete
+this.legacyThing.DoWork();
+#pragma warning restore CS0618 // Type or member is obsolete
+```
### Async patterns
The codebase is migrating to async
diff --git a/dotnet/src/webdriver/Firefox/FirefoxExtension.cs b/dotnet/src/webdriver/Firefox/FirefoxExtension.cs
index be47e57e8a8f5..ce75367008141 100644
--- a/dotnet/src/webdriver/Firefox/FirefoxExtension.cs
+++ b/dotnet/src/webdriver/Firefox/FirefoxExtension.cs
@@ -29,6 +29,7 @@ namespace OpenQA.Selenium.Firefox;
///
/// Provides the ability to install extensions into a .
///
+[Obsolete("Use FirefoxDriver.InstallAddOnFromFile instead.")]
public class FirefoxExtension
{
private const string EmNamespaceUri = "http://www.mozilla.org/2004/em-rdf#";
diff --git a/dotnet/src/webdriver/Firefox/FirefoxProfile.cs b/dotnet/src/webdriver/Firefox/FirefoxProfile.cs
index 17619687051e2..ce0547d767450 100644
--- a/dotnet/src/webdriver/Firefox/FirefoxProfile.cs
+++ b/dotnet/src/webdriver/Firefox/FirefoxProfile.cs
@@ -33,7 +33,9 @@ public class FirefoxProfile
private readonly string? sourceProfileDir;
private readonly bool deleteSource;
private readonly Preferences profilePreferences;
+#pragma warning disable CS0618 // Type or member is obsolete
private readonly Dictionary extensions = new Dictionary();
+#pragma warning restore CS0618 // Type or member is obsolete
///
/// Initializes a new instance of the class.
@@ -103,11 +105,14 @@ public static FirefoxProfile FromBase64String(string base64)
///
/// The path to the new extension
/// If is .
+ [Obsolete("Use FirefoxDriver.InstallAddOnFromFile instead.")]
public void AddExtension(string extensionToInstall)
{
ArgumentNullException.ThrowIfNull(extensionToInstall);
+#pragma warning disable CS0618 // Type or member is obsolete
this.extensions.Add(Path.GetFileNameWithoutExtension(extensionToInstall), new FirefoxExtension(extensionToInstall));
+#pragma warning restore CS0618 // Type or member is obsolete
}
///
@@ -236,10 +241,12 @@ private void DeleteLockFiles(string profileDirectory)
///
private void InstallExtensions(string profileDirectory)
{
+#pragma warning disable CS0618 // Type or member is obsolete
foreach (string extensionKey in this.extensions.Keys)
{
this.extensions[extensionKey].Install(profileDirectory);
}
+#pragma warning restore CS0618 // Type or member is obsolete
}
///
diff --git a/java/src/org/openqa/selenium/firefox/ClasspathExtension.java b/java/src/org/openqa/selenium/firefox/ClasspathExtension.java
index ce2dc1283dd5a..0a5d68e4cc4af 100644
--- a/java/src/org/openqa/selenium/firefox/ClasspathExtension.java
+++ b/java/src/org/openqa/selenium/firefox/ClasspathExtension.java
@@ -25,6 +25,10 @@
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.io.FileHandler;
+/**
+ * @deprecated Use {@link HasExtensions#installExtension} instead.
+ */
+@Deprecated(forRemoval = true)
public class ClasspathExtension implements Extension {
private final Class> loadResourcesUsing;
private final String loadFrom;
diff --git a/java/src/org/openqa/selenium/firefox/Extension.java b/java/src/org/openqa/selenium/firefox/Extension.java
index 629adb4762724..86a8d417e9a5b 100644
--- a/java/src/org/openqa/selenium/firefox/Extension.java
+++ b/java/src/org/openqa/selenium/firefox/Extension.java
@@ -20,6 +20,10 @@
import java.io.File;
import java.io.IOException;
+/**
+ * @deprecated Use {@link HasExtensions#installExtension} instead.
+ */
+@Deprecated(forRemoval = true)
public interface Extension {
void writeTo(File parentDirectory) throws IOException;
}
diff --git a/java/src/org/openqa/selenium/firefox/FileExtension.java b/java/src/org/openqa/selenium/firefox/FileExtension.java
index db9e755f00527..57746c152750a 100644
--- a/java/src/org/openqa/selenium/firefox/FileExtension.java
+++ b/java/src/org/openqa/selenium/firefox/FileExtension.java
@@ -47,6 +47,10 @@
import org.w3c.dom.Document;
import org.w3c.dom.Node;
+/**
+ * @deprecated Use {@link HasExtensions#installExtension} instead.
+ */
+@Deprecated(forRemoval = true)
public class FileExtension implements Extension {
private static final String EM_NAMESPACE_URI = "http://www.mozilla.org/2004/em-rdf#";
diff --git a/java/src/org/openqa/selenium/firefox/FirefoxProfile.java b/java/src/org/openqa/selenium/firefox/FirefoxProfile.java
index 023bf8571cf40..7fbfe921b6c21 100644
--- a/java/src/org/openqa/selenium/firefox/FirefoxProfile.java
+++ b/java/src/org/openqa/selenium/firefox/FirefoxProfile.java
@@ -38,7 +38,10 @@ public class FirefoxProfile {
private static final String ACCEPT_UNTRUSTED_CERTS_PREF = "webdriver_accept_untrusted_certs";
private static final String ASSUME_UNTRUSTED_ISSUER_PREF = "webdriver_assume_untrusted_issuer";
private final Preferences additionalPrefs;
+
+ @SuppressWarnings("deprecation")
private final Map extensions = new HashMap<>();
+
private @Nullable final File model;
private boolean loadNoFocusLib;
private boolean acceptUntrustedCerts;
@@ -145,6 +148,10 @@ public boolean containsWebDriverExtension() {
return extensions.containsKey("webdriver");
}
+ /**
+ * @deprecated Use {@link HasExtensions#installExtension} instead.
+ */
+ @Deprecated(forRemoval = true)
public void addExtension(Class> loadResourcesUsing, String loadFrom) {
// Is loadFrom a file?
File file = new File(loadFrom);
@@ -160,11 +167,17 @@ public void addExtension(Class> loadResourcesUsing, String loadFrom) {
* Attempt to add an extension to install into this instance.
*
* @param extensionToInstall File pointing to the extension
+ * @deprecated Use {@link HasExtensions#installExtension} instead.
*/
+ @Deprecated(forRemoval = true)
public void addExtension(File extensionToInstall) {
addExtension(extensionToInstall.getName(), new FileExtension(extensionToInstall));
}
+ /**
+ * @deprecated Use {@link HasExtensions#installExtension} instead.
+ */
+ @Deprecated(forRemoval = true)
public void addExtension(String key, Extension extension) {
String name = deriveExtensionName(key);
extensions.put(name, extension);
@@ -248,7 +261,9 @@ public void deleteExtensionsCacheIfItExists(File profileDir) {
* even if native events are disabled.
*
* @return Whether the no focus library should always be loaded for Firefox on Linux.
+ * @deprecated Native events are no longer supported.
*/
+ @Deprecated(forRemoval = true)
public boolean shouldLoadNoFocusLib() {
return loadNoFocusLib;
}
@@ -257,7 +272,9 @@ public boolean shouldLoadNoFocusLib() {
* Sets whether the no focus library should always be loaded on Linux.
*
* @param loadNoFocusLib Whether to always load the no focus library.
+ * @deprecated Native events are no longer supported.
*/
+ @Deprecated(forRemoval = true)
public FirefoxProfile setAlwaysLoadNoFocusLib(boolean loadNoFocusLib) {
this.loadNoFocusLib = loadNoFocusLib;
return this;
@@ -268,7 +285,9 @@ public FirefoxProfile setAlwaysLoadNoFocusLib(boolean loadNoFocusLib) {
* authority or are generally untrusted. This is set to true by default.
*
* @param acceptUntrustedSsl Whether untrusted SSL certificates should be accepted.
+ * @deprecated Use {@link FirefoxOptions#setAcceptInsecureCerts(boolean)} instead.
*/
+ @Deprecated(forRemoval = true)
public FirefoxProfile setAcceptUntrustedCertificates(boolean acceptUntrustedSsl) {
this.acceptUntrustedCerts = acceptUntrustedSsl;
return this;
@@ -287,7 +306,9 @@ public FirefoxProfile setAcceptUntrustedCertificates(boolean acceptUntrustedSsl)
* production certificate served in a testing environment) set this to false.
*
* @param untrustedIssuer whether to assume untrusted issuer or not.
+ * @deprecated Use {@link FirefoxOptions#setAcceptInsecureCerts(boolean)} instead.
*/
+ @Deprecated(forRemoval = true)
public FirefoxProfile setAssumeUntrustedCertificateIssuer(boolean untrustedIssuer) {
this.untrustedCertIssuer = untrustedIssuer;
return this;
@@ -347,6 +368,7 @@ protected void copyModel(@Nullable File sourceDir, File profileDir) throws IOExc
FileHandler.copy(sourceDir, profileDir);
}
+ @SuppressWarnings("deprecation")
protected void installExtensions(File parentDir) throws IOException {
File extensionsDir = new File(parentDir, "extensions");
diff --git a/javascript/selenium-webdriver/firefox.js b/javascript/selenium-webdriver/firefox.js
index d97500398fb99..e18d6712f9880 100644
--- a/javascript/selenium-webdriver/firefox.js
+++ b/javascript/selenium-webdriver/firefox.js
@@ -317,6 +317,7 @@ class Options extends Capabilities {
*
* @param {...string} paths The paths to the extension XPI files to install.
* @return {!Options} A self reference.
+ * @deprecated Use {@link Driver#installAddon} instead.
*/
addExtensions(...paths) {
this.profile_().addExtensions(paths)
diff --git a/rb/lib/selenium/webdriver/firefox/profile.rb b/rb/lib/selenium/webdriver/firefox/profile.rb
index 55d7d7bc1afb6..5166d211a7b0d 100644
--- a/rb/lib/selenium/webdriver/firefox/profile.rb
+++ b/rb/lib/selenium/webdriver/firefox/profile.rb
@@ -40,7 +40,6 @@ class Profile
LOCK_FILES = %w[.parentlock parent.lock lock].freeze
attr_reader :name, :log_file
- attr_writer :secure_ssl, :load_no_focus_lib
class << self
def ini
@@ -110,19 +109,28 @@ def []=(key, value)
end
def port=(port)
+ WebDriver.logger.deprecate('Firefox::Profile#port=', 'the Service class', id: :firefox_profile)
self[WEBDRIVER_PREFS[:port]] = port
end
+ def secure_ssl=(value)
+ WebDriver.logger.deprecate('Firefox::Profile#secure_ssl=', id: :firefox_profile)
+ @secure_ssl = value
+ end
+
+ def load_no_focus_lib=(value)
+ WebDriver.logger.deprecate('Firefox::Profile#load_no_focus_lib=', id: :firefox_profile)
+ @load_no_focus_lib = value
+ end
+
def log_file=(file)
@log_file = file
self[WEBDRIVER_PREFS[:log_file]] = file
end
- #
- # Add the extension (directory, .zip or .xpi) at the given path to the profile.
- #
-
def add_extension(path, name = extension_name_for(path))
+ WebDriver.logger.deprecate('Firefox::Profile#add_extension', 'Driver#install_addon',
+ id: :firefox_profile)
@extensions[name] = Extension.new(path)
end
diff --git a/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb b/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb
index ae54cd5167234..abf6586a8a20d 100644
--- a/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb
+++ b/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb
@@ -45,6 +45,12 @@ module Firefox
end
end
end
+
+ it 'ships preferences from an existing profile directory' do
+ reset_driver!(profile: described_class.new(profile.layout_on_disk)) do |driver|
+ expect { wait(5).until { driver.find_element(id: 'oneline') } }.not_to raise_error
+ end
+ end
end
end # Firefox
end # WebDriver
diff --git a/rb/spec/unit/selenium/webdriver/firefox/profile_spec.rb b/rb/spec/unit/selenium/webdriver/firefox/profile_spec.rb
index 7a460764f227e..154133fc01861 100644
--- a/rb/spec/unit/selenium/webdriver/firefox/profile_spec.rb
+++ b/rb/spec/unit/selenium/webdriver/firefox/profile_spec.rb
@@ -122,28 +122,6 @@ def read_generated_prefs(from = nil)
expect(read_generated_prefs).to include('user_pref("network.proxy.type", 4)')
end
-
- it 'can install extension' do
- firebug = File.expand_path('../../../../../../third_party/firebug/firebug-1.5.0-fx.xpi', __dir__)
- profile.add_extension(firebug)
- extension_directory = File.expand_path('extensions/firebug@software.joehewitt.com', profile.layout_on_disk)
- expect(Dir.exist?(extension_directory)).to be(true)
- end
-
- it 'can install web extension without id' do
- mooltipass = File.expand_path('../../../../../../third_party/firebug/mooltipass-1.1.87.xpi', __dir__)
- profile.add_extension(mooltipass)
- extension_directory = File.expand_path('extensions/MooltipassExtension@1.1.87', profile.layout_on_disk)
- expect(Dir.exist?(extension_directory)).to be(true)
- end
-
- it 'can install web extension with id' do
- ext = File.expand_path('../../../../../../third_party/firebug/favourite_colour-1.1-an+fx.xpi', __dir__)
- profile.add_extension(ext)
- extension_directory = File.expand_path('extensions/favourite-colour-examples@mozilla.org',
- profile.layout_on_disk)
- expect(Dir.exist?(extension_directory)).to be(true)
- end
end
end # Firefox
end # WebDriver